@zoralabs/protocol-sdk 0.7.6 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
 
2
- > @zoralabs/protocol-sdk@0.7.6 build /home/runner/work/zora-protocol-private/zora-protocol-private/packages/protocol-sdk
2
+ > @zoralabs/protocol-sdk@0.8.0 build /home/runner/work/zora-protocol-private/zora-protocol-private/packages/protocol-sdk
3
3
  > pnpm tsup
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -10,9 +10,9 @@ CLI Target: es2021
10
10
  CLI Cleaning output folder
11
11
  CJS Build start
12
12
  ESM Build start
13
- CJS dist/index.cjs 184.43 KB
14
- CJS dist/index.cjs.map 366.90 KB
15
- CJS ⚡️ Build success in 300ms
16
- ESM dist/index.js 178.86 KB
17
- ESM dist/index.js.map 364.87 KB
18
- ESM ⚡️ Build success in 341ms
13
+ CJS dist/index.cjs 186.44 KB
14
+ CJS dist/index.cjs.map 370.62 KB
15
+ CJS ⚡️ Build success in 363ms
16
+ ESM dist/index.js 180.70 KB
17
+ ESM dist/index.js.map 368.58 KB
18
+ ESM ⚡️ Build success in 392ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @zoralabs/protocol-sdk
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5417f4dd: ProtocolSdk `create1155` can only be used for new contracts, and returns the correct deterministic contract address. A new function `create1155OnExistingContract` is added to support creating 1155 tokens on existing contracts
8
+
3
9
  ## 0.7.6
4
10
 
5
11
  ### Patch Changes
@@ -1,15 +1,17 @@
1
- import type { Account, Address, Hex, PublicClient, SimulateContractParameters, TransactionReceipt } from "viem";
2
- import { CreateNew1155Params, New1155Token } from "./types";
3
- export declare const getTokenIdFromCreateReceipt: (receipt: TransactionReceipt) => bigint | undefined;
4
- type CreateNew1155TokenReturn = {
5
- parameters: SimulateContractParameters<any, any, any, any, any, Account | Address>;
1
+ import type { Account, Address, Hex, PublicClient, TransactionReceipt } from "viem";
2
+ import { CreateNew1155ContractAndTokenReturn, CreateNew1155ContractParams, CreateNew1155TokenParams, CreateNew1155TokenReturn, NewContractParams } from "./types";
3
+ export declare const getTokenIdFromCreateReceipt: (receipt: TransactionReceipt) => bigint;
4
+ export declare const getContractAddressFromReceipt: (receipt: TransactionReceipt) => Address;
5
+ type MakeContractParametersBase = {
6
+ account: Address | Account;
6
7
  tokenSetupActions: Hex[];
7
- collectionAddress: Address;
8
- newTokenId: bigint;
9
- newToken: New1155Token;
10
- minter: Address;
11
- contractExists: boolean;
12
8
  };
9
+ export declare function makeCreateContractAndTokenCall({ account, contract, royaltyBPS, fundsRecipient, tokenSetupActions, chainId, }: {
10
+ chainId: number;
11
+ contract: NewContractParams;
12
+ royaltyBPS?: number;
13
+ fundsRecipient?: Address;
14
+ } & MakeContractParametersBase): import("../types").SimulateContractParametersWithAccount;
13
15
  export declare class Create1155Client {
14
16
  private readonly chainId;
15
17
  private readonly publicClient;
@@ -17,7 +19,8 @@ export declare class Create1155Client {
17
19
  chainId: number;
18
20
  publicClient: Pick<PublicClient, "readContract">;
19
21
  });
20
- createNew1155Token(props: CreateNew1155Params): Promise<CreateNew1155TokenReturn>;
22
+ createNew1155(props: CreateNew1155ContractParams): Promise<CreateNew1155ContractAndTokenReturn>;
23
+ createNew1155OnExistingContract({ contractAddress: contract, account, token, getAdditionalSetupActions, }: CreateNew1155TokenParams): Promise<CreateNew1155TokenReturn>;
21
24
  }
22
25
  export {};
23
26
  //# sourceMappingURL=1155-create-helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"1155-create-helper.d.ts","sourceRoot":"","sources":["../../src/create/1155-create-helper.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,GAAG,EACH,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,EACnB,MAAM,MAAM,CAAC;AAId,OAAO,EAAgB,mBAAmB,E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AAO,CAAC;IAE3B,iBAAiB,EAAE,GAAG,EAAE,CAAC;CAC1B,CAAC;AAEF,wBAAgB,8BAA8B,CAAC,EAC7C,OAAO,EACP,QAAQ,EACR,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,OAAO,GACR,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,0BAA0B,4DAwB7B;AAkBD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqC;gBAEtD,EACV,OAAO,EACP,YAAY,GACb,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;KAClD;IAKK,aAAa,CACjB,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,mCAAmC,CAAC;IAQzC,+BAA+B,CAAC,EACpC,eAAe,EAAE,QAAQ,EACzB,OAAO,EACP,KAAK,EACL,yBAAyB,GAC1B,EAAE,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAUhE"}
@@ -1,14 +1,18 @@
1
- import { Address, PublicClient } from "viem";
2
- import { ContractType } from "./types";
3
- export declare function getContractInfo({ publicClient, chainId, contract, account, }: {
1
+ import { Address, Hex, PublicClient } from "viem";
2
+ import { NewContractParams } from "./types";
3
+ export declare function new1155ContractVersion(chainId: number): string;
4
+ export declare function getContractInfoExistingContract({ publicClient, contractAddress, }: {
4
5
  publicClient: Pick<PublicClient, "readContract">;
5
- chainId: number;
6
- contract: ContractType;
7
- account: Address;
8
- }): Promise<{
9
- contractExists: boolean;
10
6
  contractAddress: Address;
7
+ }): Promise<{
11
8
  contractVersion: string;
12
9
  nextTokenId: bigint;
13
10
  }>;
11
+ export declare function getDeterministicContractAddress({ publicClient, account, setupActions, contract, chainId, }: {
12
+ account: Address;
13
+ publicClient: Pick<PublicClient, "readContract">;
14
+ setupActions: Hex[];
15
+ contract: NewContractParams;
16
+ chainId: number;
17
+ }): Promise<Address>;
14
18
  //# sourceMappingURL=contract-setup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-setup.d.ts","sourceRoot":"","sources":["../../src/create/contract-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAkBvC,wBAAsB,eAAe,CAAC,EACpC,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,OAAO,GACR,EAAE;IACD,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IAEvB,OAAO,EAAE,OAAO,CAAC;CAClB,GAAG,OAAO,CAAC;IACV,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAoDD"}
1
+ {"version":3,"file":"contract-setup.d.ts","sourceRoot":"","sources":["../../src/create/contract-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAOlD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ9D;AAED,wBAAsB,+BAA+B,CAAC,EACpD,YAAY,EACZ,eAAe,GAChB,EAAE;IACD,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IACjD,eAAe,EAAE,OAAO,CAAC;CAE1B,GAAG,OAAO,CAAC;IACV,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CA0BD;AAED,wBAAsB,+BAA+B,CAAC,EACpD,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,OAAO,GACR,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IACjD,YAAY,EAAE,GAAG,EAAE,CAAC;IACpB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;CAEjB,GAAG,OAAO,CAAC,OAAO,CAAC,CAkBnB"}
@@ -1,10 +1,10 @@
1
1
  import { Concrete } from "src/utils";
2
- import { Address, Hex } from "viem";
3
- export type ContractType = {
2
+ import { Account, Address, Hex, SimulateContractParameters } from "viem";
3
+ export type NewContractParams = {
4
4
  name: string;
5
5
  uri: string;
6
6
  defaultAdmin?: Address;
7
- } | Address;
7
+ };
8
8
  export type SalesConfigParamsType = {
9
9
  pricePerToken?: bigint;
10
10
  saleStart?: bigint;
@@ -12,15 +12,19 @@ export type SalesConfigParamsType = {
12
12
  maxTokensPerAddress?: bigint;
13
13
  currency?: Address;
14
14
  };
15
- export type CreateNew1155Params = {
15
+ export type CreateNew1155ParamsBase = {
16
16
  account: Address;
17
- contract: ContractType;
18
17
  getAdditionalSetupActions?: (args: {
19
18
  tokenId: bigint;
20
- contractAddress: Address;
21
19
  }) => Hex[];
22
20
  token: CreateNew1155TokenProps;
23
21
  };
22
+ export type CreateNew1155ContractParams = CreateNew1155ParamsBase & {
23
+ contract: NewContractParams;
24
+ };
25
+ export type CreateNew1155TokenParams = CreateNew1155ParamsBase & {
26
+ contractAddress: Address;
27
+ };
24
28
  export interface CreateNew1155TokenProps {
25
29
  maxSupply?: bigint | number;
26
30
  tokenMetadataURI: string;
@@ -42,4 +46,15 @@ export type New1155Token = {
42
46
  salesConfig: Concrete<SalesConfigParamsType>;
43
47
  tokenMetadataURI: string;
44
48
  };
49
+ export type CreateNew1155TokenReturn = {
50
+ parameters: SimulateContractParameters<any, any, any, any, any, Account | Address>;
51
+ tokenSetupActions: Hex[];
52
+ newTokenId: bigint;
53
+ newToken: New1155Token;
54
+ minter: Address;
55
+ contractVersion: string;
56
+ };
57
+ export type CreateNew1155ContractAndTokenReturn = {
58
+ contractAddress: Address;
59
+ } & CreateNew1155TokenReturn;
45
60
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/create/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEpC,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GACD,OAAO,CAAC;AAEZ,MAAM,MAAM,qBAAqB,GAAG;IAElC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;IACvB,yBAAyB,CAAC,EAAE,CAAC,IAAI,EAAE;QACjC,OAAO,EAAE,MAAM,CAAC;QAChB,eAAe,EAAE,OAAO,CAAC;KAC1B,KAAK,GAAG,EAAE,CAAC;IACZ,KAAK,EAAE,uBAAuB,CAAC;CAChC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,gBA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EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG;IAChD,eAAe,EAAE,OAAO,CAAC;CAC1B,GAAG,wBAAwB,CAAC"}
package/dist/index.cjs CHANGED
@@ -1956,6 +1956,7 @@ __export(src_exports, {
1956
1956
  encodePremintForAPI: () => encodePremintForAPI,
1957
1957
  generateTextNftMetadataFiles: () => generateTextNftMetadataFiles,
1958
1958
  getApiNetworkConfigForChain: () => getApiNetworkConfigForChain,
1959
+ getContractAddressFromReceipt: () => getContractAddressFromReceipt,
1959
1960
  getDataFromPremintReceipt: () => getDataFromPremintReceipt,
1960
1961
  getDefaultFixedPriceMinterAddress: () => getDefaultFixedPriceMinterAddress,
1961
1962
  getMintsAccountBalanceWithPriceQuery: () => getMintsAccountBalanceWithPriceQuery,
@@ -1973,6 +1974,7 @@ __export(src_exports, {
1973
1974
  isPremintConfigV1: () => isPremintConfigV1,
1974
1975
  isPremintConfigV2: () => isPremintConfigV2,
1975
1976
  isValidSignature: () => isValidSignature,
1977
+ makeCreateContractAndTokenCall: () => makeCreateContractAndTokenCall,
1976
1978
  makeMediaTokenMetadata: () => makeMediaTokenMetadata,
1977
1979
  makeMintRewardsRecipient: () => makeMintRewardsRecipient,
1978
1980
  makeNewPremint: () => makeNewPremint,
@@ -4130,49 +4132,51 @@ function new1155ContractVersion(chainId) {
4130
4132
  }
4131
4133
  return address.CONTRACT_1155_IMPL_VERSION;
4132
4134
  }
4133
- async function getContractInfo({
4135
+ async function getContractInfoExistingContract({
4134
4136
  publicClient,
4135
- chainId,
4136
- contract,
4137
- account
4137
+ contractAddress
4138
4138
  }) {
4139
- const contractAddress = typeof contract === "string" ? contract : await publicClient.readContract({
4140
- abi: import_protocol_deployments7.zoraCreator1155FactoryImplABI,
4141
- // Since this address is deterministic we can hardcode a chain id safely here.
4142
- address: import_protocol_deployments7.zoraCreator1155FactoryImplAddress[chainId],
4143
- functionName: "deterministicContractAddress",
4144
- args: [
4145
- account,
4146
- contract.uri,
4147
- contract.name,
4148
- contract.defaultAdmin || account
4149
- ]
4150
- });
4151
4139
  let contractVersion;
4152
- let contractExists;
4153
4140
  try {
4154
4141
  contractVersion = await publicClient.readContract({
4155
4142
  abi: import_protocol_deployments7.zoraCreator1155ImplABI,
4156
4143
  address: contractAddress,
4157
4144
  functionName: "contractVersion"
4158
4145
  });
4159
- contractExists = true;
4160
4146
  } catch (e) {
4161
- contractVersion = new1155ContractVersion(chainId);
4162
- contractExists = false;
4147
+ throw new Error(`Contract does not exist at ${contractAddress}`);
4163
4148
  }
4164
- const nextTokenId = contractExists ? await publicClient.readContract({
4149
+ const nextTokenId = await publicClient.readContract({
4165
4150
  address: contractAddress,
4166
4151
  abi: import_protocol_deployments7.zoraCreator1155ImplABI,
4167
4152
  functionName: "nextTokenId"
4168
- }) : 1n;
4153
+ });
4169
4154
  return {
4170
- contractExists,
4171
- contractAddress,
4172
4155
  contractVersion,
4173
4156
  nextTokenId
4174
4157
  };
4175
4158
  }
4159
+ async function getDeterministicContractAddress({
4160
+ publicClient,
4161
+ account,
4162
+ setupActions,
4163
+ contract,
4164
+ chainId
4165
+ }) {
4166
+ const contractAddress = await publicClient.readContract({
4167
+ abi: import_protocol_deployments7.zoraCreator1155FactoryImplABI,
4168
+ address: import_protocol_deployments7.zoraCreator1155FactoryImplAddress[chainId],
4169
+ functionName: "deterministicContractAddressWithSetupActions",
4170
+ args: [
4171
+ account,
4172
+ contract.uri,
4173
+ contract.name,
4174
+ contract.defaultAdmin || account,
4175
+ setupActions
4176
+ ]
4177
+ });
4178
+ return contractAddress;
4179
+ }
4176
4180
 
4177
4181
  // src/create/token-setup.ts
4178
4182
  var import_protocol_deployments8 = require("@zoralabs/protocol-deployments");
@@ -4454,43 +4458,61 @@ var getTokenIdFromCreateReceipt = (receipt) => {
4454
4458
  } catch (err) {
4455
4459
  }
4456
4460
  }
4461
+ throw new Error(
4462
+ "No event found in receipt that could be used to get tokenId"
4463
+ );
4464
+ };
4465
+ var getContractAddressFromReceipt = (receipt) => {
4466
+ for (const data of receipt.logs) {
4467
+ try {
4468
+ const decodedLog = (0, import_viem8.decodeEventLog)({
4469
+ abi: import_protocol_deployments9.zoraCreator1155FactoryImplABI,
4470
+ eventName: "SetupNewContract",
4471
+ ...data
4472
+ });
4473
+ if (decodedLog && decodedLog.eventName === "SetupNewContract") {
4474
+ return decodedLog.args.newContract;
4475
+ }
4476
+ } catch (err) {
4477
+ }
4478
+ }
4479
+ throw new Error(
4480
+ "No event found in receipt that could be used to get contract address"
4481
+ );
4457
4482
  };
4458
4483
  function makeCreateContractAndTokenCall({
4459
- contractExists,
4460
- contractAddress,
4461
- contract,
4462
4484
  account,
4485
+ contract,
4463
4486
  royaltyBPS,
4487
+ fundsRecipient,
4464
4488
  tokenSetupActions,
4465
- fundsRecipient
4489
+ chainId
4490
+ }) {
4491
+ const accountAddress = typeof account === "string" ? account : account.address;
4492
+ return makeContractParameters({
4493
+ abi: import_protocol_deployments9.zoraCreator1155FactoryImplABI,
4494
+ functionName: "createContractDeterministic",
4495
+ account,
4496
+ address: import_protocol_deployments9.zoraCreator1155FactoryImplAddress[chainId],
4497
+ args: [
4498
+ contract.uri,
4499
+ contract.name,
4500
+ {
4501
+ // deprecated
4502
+ royaltyMintSchedule: 0,
4503
+ royaltyBPS: royaltyBPS || ROYALTY_BPS_DEFAULT,
4504
+ royaltyRecipient: fundsRecipient || accountAddress
4505
+ },
4506
+ contract.defaultAdmin || accountAddress,
4507
+ tokenSetupActions
4508
+ ]
4509
+ });
4510
+ }
4511
+ function makeCreateTokenCall({
4512
+ contractAddress,
4513
+ account,
4514
+ tokenSetupActions
4466
4515
  }) {
4467
- if (!contractAddress && typeof contract === "string") {
4468
- throw new Error("Invariant: contract cannot be missing and an address");
4469
- }
4470
- if (!contractExists) {
4471
- if (typeof contract === "string") {
4472
- throw new Error("Invariant: expected contract object");
4473
- }
4474
- const accountAddress = typeof account === "string" ? account : account.address;
4475
- return makeContractParameters({
4476
- abi: import_protocol_deployments9.zoraCreator1155FactoryImplABI,
4477
- functionName: "createContractDeterministic",
4478
- account,
4479
- address: import_protocol_deployments9.zoraCreator1155FactoryImplAddress[999],
4480
- args: [
4481
- contract.uri,
4482
- contract.name,
4483
- {
4484
- // deprecated
4485
- royaltyMintSchedule: 0,
4486
- royaltyBPS: royaltyBPS || ROYALTY_BPS_DEFAULT,
4487
- royaltyRecipient: fundsRecipient || accountAddress
4488
- },
4489
- contract.defaultAdmin || accountAddress,
4490
- tokenSetupActions
4491
- ]
4492
- });
4493
- }
4494
4516
  return makeContractParameters({
4495
4517
  abi: import_protocol_deployments9.zoraCreator1155ImplABI,
4496
4518
  functionName: "multicall",
@@ -4507,65 +4529,141 @@ var Create1155Client = class {
4507
4529
  this.chainId = chainId;
4508
4530
  this.publicClient = publicClient;
4509
4531
  }
4510
- async createNew1155Token(props) {
4511
- return createNew1155Token({
4532
+ async createNew1155(props) {
4533
+ return createNew1155ContractAndToken({
4512
4534
  ...props,
4513
4535
  publicClient: this.publicClient,
4514
4536
  chainId: this.chainId
4515
4537
  });
4516
4538
  }
4539
+ async createNew1155OnExistingContract({
4540
+ contractAddress: contract,
4541
+ account,
4542
+ token,
4543
+ getAdditionalSetupActions
4544
+ }) {
4545
+ return createNew1155Token({
4546
+ contractAddress: contract,
4547
+ account,
4548
+ token,
4549
+ getAdditionalSetupActions,
4550
+ publicClient: this.publicClient,
4551
+ chainId: this.chainId
4552
+ });
4553
+ }
4517
4554
  };
4518
- async function createNew1155Token({
4555
+ async function createNew1155ContractAndToken({
4519
4556
  contract,
4520
4557
  account,
4558
+ chainId,
4559
+ token,
4560
+ publicClient,
4561
+ getAdditionalSetupActions
4562
+ }) {
4563
+ const nextTokenId = 1n;
4564
+ const contractVersion = new1155ContractVersion(chainId);
4565
+ const {
4566
+ minter,
4567
+ newToken,
4568
+ setupActions: tokenSetupActions
4569
+ } = prepareSetupActions({
4570
+ chainId,
4571
+ account,
4572
+ contractVersion,
4573
+ nextTokenId,
4574
+ token,
4575
+ getAdditionalSetupActions
4576
+ });
4577
+ const request = makeCreateContractAndTokenCall({
4578
+ contract,
4579
+ account,
4580
+ chainId,
4581
+ tokenSetupActions,
4582
+ fundsRecipient: token.payoutRecipient,
4583
+ royaltyBPS: token.royaltyBPS
4584
+ });
4585
+ const contractAddress = await getDeterministicContractAddress({
4586
+ account,
4587
+ publicClient,
4588
+ setupActions: tokenSetupActions,
4589
+ chainId,
4590
+ contract
4591
+ });
4592
+ return {
4593
+ parameters: request,
4594
+ tokenSetupActions,
4595
+ newTokenId: nextTokenId,
4596
+ newToken,
4597
+ contractAddress,
4598
+ contractVersion,
4599
+ minter
4600
+ };
4601
+ }
4602
+ async function createNew1155Token({
4603
+ contractAddress,
4604
+ account,
4521
4605
  getAdditionalSetupActions,
4522
- token: tokenConfig,
4606
+ token,
4523
4607
  publicClient,
4524
4608
  chainId
4525
4609
  }) {
4526
- const { contractExists, contractAddress, nextTokenId, contractVersion } = await getContractInfo({
4610
+ const { nextTokenId, contractVersion } = await getContractInfoExistingContract({
4527
4611
  publicClient,
4528
- chainId,
4529
- contract,
4530
- account
4612
+ contractAddress
4531
4613
  });
4532
4614
  const {
4533
4615
  minter,
4534
4616
  newToken,
4535
4617
  setupActions: tokenSetupActions
4536
- } = constructCreate1155TokenCalls({
4618
+ } = prepareSetupActions({
4537
4619
  chainId,
4538
- ownerAddress: account,
4620
+ account,
4539
4621
  contractVersion,
4540
4622
  nextTokenId,
4541
- ...tokenConfig
4623
+ token,
4624
+ getAdditionalSetupActions
4542
4625
  });
4543
- const setupActions = getAdditionalSetupActions ? [
4544
- ...getAdditionalSetupActions({
4545
- tokenId: nextTokenId,
4546
- contractAddress
4547
- }),
4548
- ...tokenSetupActions
4549
- ] : tokenSetupActions;
4550
- const request = makeCreateContractAndTokenCall({
4551
- contractExists,
4626
+ const request = makeCreateTokenCall({
4552
4627
  contractAddress,
4553
- contract,
4554
4628
  account,
4555
- tokenSetupActions: setupActions,
4556
- royaltyBPS: tokenConfig.royaltyBPS,
4557
- fundsRecipient: tokenConfig.payoutRecipient
4629
+ tokenSetupActions
4558
4630
  });
4559
4631
  return {
4560
4632
  parameters: request,
4561
4633
  tokenSetupActions,
4562
- collectionAddress: contractAddress,
4563
- contractExists,
4564
4634
  newTokenId: nextTokenId,
4565
4635
  newToken,
4636
+ contractVersion,
4566
4637
  minter
4567
4638
  };
4568
4639
  }
4640
+ function prepareSetupActions({
4641
+ chainId,
4642
+ account,
4643
+ contractVersion,
4644
+ nextTokenId,
4645
+ token,
4646
+ getAdditionalSetupActions
4647
+ }) {
4648
+ const {
4649
+ minter,
4650
+ newToken,
4651
+ setupActions: tokenSetupActions
4652
+ } = constructCreate1155TokenCalls({
4653
+ chainId,
4654
+ ownerAddress: account,
4655
+ contractVersion,
4656
+ nextTokenId,
4657
+ ...token
4658
+ });
4659
+ const setupActions = getAdditionalSetupActions ? [
4660
+ ...getAdditionalSetupActions({
4661
+ tokenId: nextTokenId
4662
+ }),
4663
+ ...tokenSetupActions
4664
+ ] : tokenSetupActions;
4665
+ return { minter, newToken, setupActions };
4666
+ }
4569
4667
 
4570
4668
  // src/sparks/mints-queries.ts
4571
4669
  var getMintsAccountBalanceWithPriceQuery = (account) => {
@@ -4870,7 +4968,8 @@ function createCreatorClient(clientConfig) {
4870
4968
  createPremint: (p) => premintClient.createPremint(p),
4871
4969
  updatePremint: (p) => premintClient.updatePremint(p),
4872
4970
  deletePremint: (p) => premintClient.deletePremint(p),
4873
- create1155: (p) => create1155CreatorClient.createNew1155Token(p)
4971
+ create1155: (p) => create1155CreatorClient.createNew1155(p),
4972
+ create1155OnExistingContract: (p) => create1155CreatorClient.createNew1155OnExistingContract(p)
4874
4973
  };
4875
4974
  }
4876
4975
  function createCollectorClient(params) {
@@ -6117,6 +6216,7 @@ async function generateTextNftMetadataFiles(text) {
6117
6216
  encodePremintForAPI,
6118
6217
  generateTextNftMetadataFiles,
6119
6218
  getApiNetworkConfigForChain,
6219
+ getContractAddressFromReceipt,
6120
6220
  getDataFromPremintReceipt,
6121
6221
  getDefaultFixedPriceMinterAddress,
6122
6222
  getMintsAccountBalanceWithPriceQuery,
@@ -6134,6 +6234,7 @@ async function generateTextNftMetadataFiles(text) {
6134
6234
  isPremintConfigV1,
6135
6235
  isPremintConfigV2,
6136
6236
  isValidSignature,
6237
+ makeCreateContractAndTokenCall,
6137
6238
  makeMediaTokenMetadata,
6138
6239
  makeMintRewardsRecipient,
6139
6240
  makeNewPremint,