Skip to content

Commit

Permalink
Merge pull request #906 from graphprotocol/mde/deploy-with-array-params
Browse files Browse the repository at this point in the history
chore: add array to constructor argument types
  • Loading branch information
Maikol committed Jan 8, 2024
2 parents 37a59dd + eabe215 commit bd2f487
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ yarn-error.log*
node_modules/

# Yarn
.yarn/*
.yarn/
!.yarn/patches
!.yarn/releases
!.yarn/plugins
Expand Down Expand Up @@ -42,4 +42,4 @@ tx-*.log
addresses-fork.json

# Keys
.keystore
.keystore
10 changes: 9 additions & 1 deletion packages/sdk/src/deployments/lib/deploy/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,18 @@ export const deployContractAndSave: DeployAddressBookFunction = async (
args: args,
})

const constructorArgs = args.map((e) => {
if (Array.isArray(e)) {
return e.map((e) => e.toString())
} else {
return e.toString()
}
})

// Save address entry
addressBook.setEntry(name, {
address: deployResult.contract.address,
constructorArgs: args.length === 0 ? undefined : args.map((e) => e.toString()),
constructorArgs: constructorArgs,
creationCodeHash: deployResult.creationCodeHash,
runtimeCodeHash: deployResult.runtimeCodeHash,
txHash: deployResult.txHash,
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk/src/deployments/lib/types/address-book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export type AddressBookJson<
ContractName extends string = string,
> = Record<ChainId, Record<ContractName, AddressBookEntry>>

export type ConstructorArg = string | Array<string>

export type AddressBookEntry = {
address: string
constructorArgs?: Array<string>
constructorArgs?: Array<ConstructorArg>
initArgs?: Array<string>
proxy?: boolean
implementation?: AddressBookEntry
Expand Down

0 comments on commit bd2f487

Please sign in to comment.