Skip to content

Conversation

@danielailie
Copy link
Contributor

No description provided.

@danielailie danielailie self-assigned this Apr 14, 2025
@popenta popenta self-requested a review April 15, 2025 08:29
@andreibancioiu andreibancioiu self-requested a review April 15, 2025 08:42
Comment on lines 52 to 54
egldAmount: bigint;
gasLimit?: bigint;
tokenTransfers: TokenTransfer[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have egldAmount and tokenTransfers as optionals? Just so the user understands they are not both mandatory. In case neither are provided we throw an error.


export type ProposeTransferExecuteInput = MultisigContractInput & {
to: Address;
egldAmount: bigint;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we usually use nativeTokenAmount.

Comment on lines 218 to 221
NativeSerializer.nativeToTypedValues(
[options.to, argsTyped, options.gasLimit, VariadicValue.fromItems(...input.functionCall)],
this.abi?.getEndpoint("proposeTransferExecuteEsdt") ??
new EndpointDefinition("proposeTransferExecuteEsdt", [], [], new EndpointModifiers("", [])),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work if the Abi is not provided?
Perhaps you could convert all values to typed values so the abi would not be needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not, but I'll do this in a different pr

popenta
popenta previously approved these changes Apr 15, 2025
Copy link
Contributor

@andreibancioiu andreibancioiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Comment on lines 42 to 45
for (let index = 1; index < functionCallParts.length; index++) {
const element = functionCallParts[index];
functionArguments.push(element.valueOf());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As below, in case Array.slice can be used.

* Use this class to create multisig related transactions like creating a new multisig contract,
* proposing actions, signing actions, and performing actions.
*/
export class MultisigTransactionsFactory extends SmartContractTransactionsFactory {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inheriting vs. doing "composition" - debatable; but here, indeed, using SmartContractTransactionsFactory as a base class seems the better choice 👍

}).build();
}

private mapTokenPayment(options: resources.ProposeTransferExecuteEsdtInput) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be plural, since there are more payments.

Also, we should specify the return type.

const argsTyped = [];
for (const token of options.tokens) {
argsTyped.push({
token_identifier: new TokenIdentifierValue(
Copy link
Contributor

@andreibancioiu andreibancioiu Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When ABI is available, I think the following is sufficient:

{
    token_identifier: tokenComputer.extractIdentifierFromExtendedIdentifier(token.token.identifier),
    token_nonce: token.token.nonce,
    amount: token.amount
}

When the ABI isn't available, this does not work at all (as far as I remember), since a StructValue is required - a mere {} object does not suffice.

Additional comments about having the ABI as required or not can be seen in the PR with the controller implementation, thus we can leave this as it is in the current PR.

These being said, argsTyped can also be renamed (here, the args aren't completely typed).

});
}

private static getFunctionCall(transaction: Transaction) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a comment to explain the workaround / hack.

In the multisig transactions factory, we leverage the generic smart contract transactions factory to properly encode the arguments (given the ABI) for the "other" contract execute proposal. However, since we have to handle them as variadic<bytes> when preparing the "top-level" multisig transaction, here we split back the data.

To-do for a future PR: convert the arguments to a list of buffers using the ArgSerializer or a SmartContractTransactionsFactory.argsToDataParts(), instead of the <create transaction using factory, then parse back into list of buffers> hack.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, this is ok for the moment as long as we add the comment. Will perhaps refactor later if needed.

assert.instanceOf(transaction, Transaction);
assert.equal(transaction.sender.toBech32(), senderAddress.toBech32());
assert.equal(transaction.receiver.toBech32(), multisigContractAddress.toBech32());
assert.isAbove(transaction.data.length, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this check is necessary since we assert on the data field bellow. not a big deal anyways

andreibancioiu
andreibancioiu previously approved these changes Apr 29, 2025
popenta
popenta previously approved these changes Apr 29, 2025
@danielailie danielailie dismissed stale reviews from popenta and andreibancioiu via 721eb9d April 29, 2025 12:21
popenta
popenta previously approved these changes Apr 29, 2025
@danielailie danielailie merged commit 683597e into feat/next Apr 29, 2025
5 checks passed
@danielailie danielailie deleted the TOOL-329-add-mustisig-factory branch April 29, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants