Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
New ContractPublisher address + fix schema validation (#539)
Browse files Browse the repository at this point in the history
* New ContractPublisher address + fix schema validation

* v2.3.35-0

* dedupe getAll contract call

* v2.3.35-1
  • Loading branch information
joaquim-verges authored Aug 10, 2022
1 parent e16e445 commit 7d32d38
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
8 changes: 4 additions & 4 deletions etc/sdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ export const CompilerMetadataFetchedSchema: z.ZodObject<{
details?: string | undefined;
notice?: string | undefined;
}>;
licenses: z.ZodArray<z.ZodString, "many">;
licenses: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
name: string;
metadata: Record<string, any>;
Expand Down Expand Up @@ -1096,6 +1096,7 @@ export const CompilerMetadataFetchedSchema: z.ZodObject<{
};
licenses: string[];
}, {
licenses?: string[] | undefined;
name: string;
metadata: Record<string, any>;
abi: {
Expand Down Expand Up @@ -1131,7 +1132,6 @@ export const CompilerMetadataFetchedSchema: z.ZodObject<{
details?: string | undefined;
notice?: string | undefined;
};
licenses: string[];
}>;

// Warning: (ae-internal-missing-underscore) The name "CONTRACT_ADDRESSES" should be prefixed with an underscore because the declaration is marked as @internal
Expand Down Expand Up @@ -4393,7 +4393,7 @@ export const PreDeployMetadataFetchedSchema: z.ZodObject<z.extendShape<z.extendS
details?: string | undefined;
notice?: string | undefined;
}>;
licenses: z.ZodArray<z.ZodString, "many">;
licenses: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
}>, {
bytecode: z.ZodString;
}>, "strip", z.ZodAny, {
Expand Down Expand Up @@ -4439,6 +4439,7 @@ export const PreDeployMetadataFetchedSchema: z.ZodObject<z.extendShape<z.extendS
bytecode: string;
}, {
[x: string]: any;
licenses?: string[] | undefined;
name: string;
metadataUri: string;
metadata: Record<string, any>;
Expand Down Expand Up @@ -4475,7 +4476,6 @@ export const PreDeployMetadataFetchedSchema: z.ZodObject<z.extendShape<z.extendS
details?: string | undefined;
notice?: string | undefined;
};
licenses: string[];
bytecodeUri: string;
bytecode: string;
}>;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/sdk",
"version": "2.3.34",
"version": "2.3.35-1",
"description": "The main thirdweb SDK.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const OZ_DEFENDER_FORWARDER_ADDRESS =

const TWRegistry_address = "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd";
const TWFactory_address = "0x5DBC7B840baa9daBcBe9D2492E45D7244B54A2A0";
const ContractPublisher_address = "0x119704314Ef304EaAAE4b3c7C9ABd59272A28310"; // Polygon only
const ContractPublisher_address = "0x58c892e6bc196371f7fb425177b0E2aA906BC007"; // Polygon only

/**
* @internal
Expand Down
12 changes: 11 additions & 1 deletion src/core/classes/contract-publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,17 @@ export class ContractPublisher extends RPCConnectionHandler {
const data = await this.publisher.readContract.getAllPublishedContracts(
publisherAddress,
);
return data.map((d) => this.toPublishedContract(d));
// since we can fetch from multiple publisher contracts, just keep the latest one in the list
const map = data.reduce<
Record<string, IContractPublisher.CustomContractInstanceStruct>
>((acc, curr) => {
// replaces the previous contract with the latest one
acc[curr.contractId] = curr;
return acc;
}, {});
return Object.entries(map).map(([_, struct]) =>
this.toPublishedContract(struct),
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/schema/contracts/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const CompilerMetadataFetchedSchema = z.object({
abi: AbiSchema,
metadata: z.record(z.string(), z.any()),
info: ContractInfoSchema,
licenses: z.array(z.string()),
licenses: z.array(z.string()).default([]),
});

/**
Expand Down

0 comments on commit 7d32d38

Please sign in to comment.