Skip to content

Commit

Permalink
feat: add multicall support
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkelawala committed Nov 1, 2022
1 parent 67fe081 commit 4b99f4a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/account/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,28 @@ export class Account extends Provider implements AccountInterface {
constructorCalldata = [],
isDevnet = false,
}: UniversalDeployerContractPayload,
additionalCalls: AllowArray<Call> = [], // support multicall
transactionsDetail: InvocationsDetails = {}
): Promise<InvokeFunctionResponse> {
const compiledConstructorCallData = compileCalldata(constructorCalldata);

const callsArray = Array.isArray(additionalCalls) ? additionalCalls : [additionalCalls];

return this.execute(
{
contractAddress: isDevnet ? UDC.ADDRESS_DEVNET : UDC.ADDRESS,
entrypoint: UDC.ENTRYPOINT,
calldata: [
classHash,
salt,
toCairoBool(unique),
compiledConstructorCallData.length,
...compiledConstructorCallData,
],
},
[
{
contractAddress: isDevnet ? UDC.ADDRESS_DEVNET : UDC.ADDRESS,
entrypoint: UDC.ENTRYPOINT,
calldata: [
classHash,
salt,
toCairoBool(unique),
compiledConstructorCallData.length,
...compiledConstructorCallData,
],
},
...callsArray,
],
undefined,
transactionsDetail
);
Expand Down
2 changes: 2 additions & 0 deletions src/account/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ export abstract class AccountInterface extends ProviderInterface {
* - salt: address salt
* - unique: bool if true ensure unique salt
* - calldata: constructor calldata
* @param additionalCalls - optional additional calls array to support multicall
* @param transactionsDetail Invocation Details containing:
* - optional nonce
* - optional version
* - optional maxFee
*/
public abstract deploy(
deployContractPayload: UniversalDeployerContractPayload,
additionalCalls?: AllowArray<Call>,
transactionsDetail?: InvocationsDetails
): Promise<any>;

Expand Down

0 comments on commit 4b99f4a

Please sign in to comment.