Skip to content

Commit ec36b13

Browse files
authored
[SDK] Improve add/removeContract method for registry.ts (#1731)
1 parent 52b1a0f commit ec36b13

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/sdk": patch
3+
---
4+
5+
Improve add/removeContract methods

packages/sdk/src/evm/core/classes/registry.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,11 @@ export class ContractRegistry extends ContractWrapper<TWRegistry> {
4848
): Promise<Transaction<TransactionResult>> => {
4949
const deployerAddress = await this.getSignerAddress();
5050
const contractEncoder = new ContractEncoder(this);
51-
const encoded: string[] = await Promise.all(
52-
contractAddresses.map(async (address) =>
53-
contractEncoder.encode("add", [
54-
deployerAddress,
55-
await resolveAddress(address),
56-
]),
57-
),
51+
const encoded = (
52+
await Promise.all(contractAddresses.map((addr) => resolveAddress(addr)))
53+
).map((address) =>
54+
contractEncoder.encode("add", [deployerAddress, address]),
5855
);
59-
6056
return Transaction.fromContractWrapper({
6157
contractWrapper: this,
6258
method: "multicall",
@@ -79,15 +75,11 @@ export class ContractRegistry extends ContractWrapper<TWRegistry> {
7975
): Promise<Transaction<TransactionResult>> => {
8076
const deployerAddress = await this.getSignerAddress();
8177
const contractEncoder = new ContractEncoder(this);
82-
const encoded: string[] = await Promise.all(
83-
contractAddresses.map(async (address) =>
84-
contractEncoder.encode("remove", [
85-
deployerAddress,
86-
await resolveAddress(address),
87-
]),
88-
),
78+
const encoded = (
79+
await Promise.all(contractAddresses.map((addr) => resolveAddress(addr)))
80+
).map((address) =>
81+
contractEncoder.encode("remove", [deployerAddress, address]),
8982
);
90-
9183
return Transaction.fromContractWrapper({
9284
contractWrapper: this,
9385
method: "multicall",

0 commit comments

Comments
 (0)