Skip to content

Commit 9db382a

Browse files
authored
Merge pull request #637 from multiversx/TOOL-644-fix-propose-transfer-execute-to-work-for-transfer-egld-only
Fix propose transfer execute to work for transfer egld only
2 parents cca633c + 63efd24 commit 9db382a

File tree

6 files changed

+80
-21
lines changed

6 files changed

+80
-21
lines changed

package-lock.json

Lines changed: 39 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@multiversx/sdk-core",
3-
"version": "14.2.8",
3+
"version": "14.2.9",
44
"description": "MultiversX SDK for JavaScript and TypeScript",
55
"author": "MultiversX",
66
"homepage": "https://multiversx.com",

src/multisig/multisigTransactionsFactory.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,30 @@ describe("test multisig transactions factory", function () {
174174
);
175175
});
176176

177+
it("should create transaction for propose transfer execute with EGLD send", function () {
178+
const senderAddress = Address.newFromBech32("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx");
179+
180+
const multisigContractAddress = Address.newFromBech32(
181+
"erd1qqqqqqqqqqqqqpgq0rffvv4vk9vesqplv9ws55fxzdfaspqa8cfszy2hms",
182+
);
183+
const amount = 1000000000000000000n; // 1 EGLD
184+
const transaction = factory.createTransactionForProposeTransferExecute(senderAddress, {
185+
multisigContract: multisigContractAddress,
186+
gasLimit: 60_000_000n,
187+
nativeTokenAmount: amount,
188+
to: multisigContractAddress,
189+
});
190+
191+
assert.instanceOf(transaction, Transaction);
192+
assert.equal(transaction.sender.toBech32(), senderAddress.toBech32());
193+
assert.equal(transaction.receiver.toBech32(), multisigContractAddress.toBech32());
194+
assert.equal(transaction.chainID, config.chainID);
195+
assert.deepEqual(
196+
transaction.data.toString(),
197+
"proposeTransferExecute@0000000000000000050078d29632acb15998003f615d0a51261353d8041d3e13@0de0b6b3a7640000@",
198+
);
199+
});
200+
177201
it("should create transaction for propose transfer execute ESDT", function () {
178202
const senderAddress = Address.newFromBech32("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx");
179203
const destinationContract = Address.newFromBech32(

src/multisig/multisigTransactionsFactory.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,18 @@ export class MultisigTransactionsFactory {
124124
sender: Address,
125125
options: resources.ProposeTransferExecuteInput,
126126
): Transaction {
127-
const gasOption = new U64Value(options.optGasLimit ?? 0n);
128-
const input = ProposeTransferExecuteContractInput.newFromTransferExecuteInput({
129-
multisig: options.multisigContract,
130-
to: options.to,
131-
functionName: options.functionName,
132-
arguments: options.functionArguments,
133-
abi: options.abi,
134-
});
127+
const gasOption = options.optGasLimit ? new U64Value(options.optGasLimit) : null;
128+
let functionCall = [];
129+
if (options.functionName) {
130+
const input = ProposeTransferExecuteContractInput.newFromTransferExecuteInput({
131+
multisig: options.multisigContract,
132+
to: options.to,
133+
functionName: options.functionName,
134+
arguments: options.functionArguments,
135+
abi: options.abi,
136+
});
137+
functionCall = input.functionCall;
138+
}
135139

136140
return this.smartContractFactory.createTransactionForExecute(sender, {
137141
contract: options.multisigContract,
@@ -141,7 +145,7 @@ export class MultisigTransactionsFactory {
141145
new AddressValue(options.to),
142146
new BigUIntValue(options.nativeTokenAmount),
143147
new OptionValue(new OptionType(new U64Type()), gasOption),
144-
VariadicValue.fromItems(...input.functionCall.map((value) => new BytesValue(value))),
148+
VariadicValue.fromItems(...functionCall.map((value) => new BytesValue(value))),
145149
],
146150
});
147151
}

src/multisig/proposeTransferExecuteContractInput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class ProposeTransferExecuteContractInput {
2121
multisig: Address;
2222
to: Address;
2323
functionName: string;
24-
arguments: any[];
24+
arguments?: any[];
2525
optGasLimit?: bigint;
2626
abi?: Abi;
2727
}): ProposeTransferExecuteContractInput {

src/multisig/resources.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export type ProposeTransferExecuteInput = MultisigContractInput & {
3939
to: Address;
4040
nativeTokenAmount: bigint;
4141
optGasLimit?: bigint;
42-
functionName: string;
43-
functionArguments: any[];
42+
functionName?: string;
43+
functionArguments?: any[];
4444
abi?: Abi;
4545
};
4646

0 commit comments

Comments
 (0)