thirdweb 5.45.1 → 5.45.2-nightly-b15aa4cdff3f3b233025da285780668a18fe29ab-20240813000336

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.
Files changed (82) hide show
  1. package/dist/cjs/exports/deploys.js +3 -1
  2. package/dist/cjs/exports/deploys.js.map +1 -1
  3. package/dist/cjs/exports/extensions/split.js +7 -1
  4. package/dist/cjs/exports/extensions/split.js.map +1 -1
  5. package/dist/cjs/extensions/prebuilts/__generated__/Split/write/initialize.js +157 -0
  6. package/dist/cjs/extensions/prebuilts/__generated__/Split/write/initialize.js.map +1 -0
  7. package/dist/cjs/extensions/prebuilts/deploy-split.js +79 -0
  8. package/dist/cjs/extensions/prebuilts/deploy-split.js.map +1 -0
  9. package/dist/cjs/extensions/split/__generated__/Split/read/totalShares.js +71 -0
  10. package/dist/cjs/extensions/split/__generated__/Split/read/totalShares.js.map +1 -0
  11. package/dist/cjs/extensions/split/read/getAllRecipientsAddresses.js +24 -0
  12. package/dist/cjs/extensions/split/read/getAllRecipientsAddresses.js.map +1 -0
  13. package/dist/cjs/extensions/split/read/getAllRecipientsPercentages.js +34 -0
  14. package/dist/cjs/extensions/split/read/getAllRecipientsPercentages.js.map +1 -0
  15. package/dist/cjs/extensions/split/read/getRecipientSplitPercentage.js +21 -0
  16. package/dist/cjs/extensions/split/read/getRecipientSplitPercentage.js.map +1 -0
  17. package/dist/cjs/react/core/hooks/auth/useSiweAuth.js +4 -0
  18. package/dist/cjs/react/core/hooks/auth/useSiweAuth.js.map +1 -1
  19. package/dist/cjs/react/core/hooks/others/useProfiles.js +1 -1
  20. package/dist/cjs/version.js +1 -1
  21. package/dist/cjs/version.js.map +1 -1
  22. package/dist/cjs/wallets/in-app/core/wallet/profiles.js +3 -3
  23. package/dist/esm/exports/deploys.js +1 -0
  24. package/dist/esm/exports/deploys.js.map +1 -1
  25. package/dist/esm/exports/extensions/split.js +3 -0
  26. package/dist/esm/exports/extensions/split.js.map +1 -1
  27. package/dist/esm/extensions/prebuilts/__generated__/Split/write/initialize.js +150 -0
  28. package/dist/esm/extensions/prebuilts/__generated__/Split/write/initialize.js.map +1 -0
  29. package/dist/esm/extensions/prebuilts/deploy-split.js +76 -0
  30. package/dist/esm/extensions/prebuilts/deploy-split.js.map +1 -0
  31. package/dist/esm/extensions/split/__generated__/Split/read/totalShares.js +65 -0
  32. package/dist/esm/extensions/split/__generated__/Split/read/totalShares.js.map +1 -0
  33. package/dist/esm/extensions/split/read/getAllRecipientsAddresses.js +21 -0
  34. package/dist/esm/extensions/split/read/getAllRecipientsAddresses.js.map +1 -0
  35. package/dist/esm/extensions/split/read/getAllRecipientsPercentages.js +31 -0
  36. package/dist/esm/extensions/split/read/getAllRecipientsPercentages.js.map +1 -0
  37. package/dist/esm/extensions/split/read/getRecipientSplitPercentage.js +18 -0
  38. package/dist/esm/extensions/split/read/getRecipientSplitPercentage.js.map +1 -0
  39. package/dist/esm/react/core/hooks/auth/useSiweAuth.js +4 -0
  40. package/dist/esm/react/core/hooks/auth/useSiweAuth.js.map +1 -1
  41. package/dist/esm/react/core/hooks/others/useProfiles.js +1 -1
  42. package/dist/esm/version.js +1 -1
  43. package/dist/esm/version.js.map +1 -1
  44. package/dist/esm/wallets/in-app/core/wallet/profiles.js +3 -3
  45. package/dist/types/exports/deploys.d.ts +1 -0
  46. package/dist/types/exports/deploys.d.ts.map +1 -1
  47. package/dist/types/exports/extensions/split.d.ts +3 -0
  48. package/dist/types/exports/extensions/split.d.ts.map +1 -1
  49. package/dist/types/extensions/prebuilts/__generated__/Split/write/initialize.d.ts +108 -0
  50. package/dist/types/extensions/prebuilts/__generated__/Split/write/initialize.d.ts.map +1 -0
  51. package/dist/types/extensions/prebuilts/deploy-split.d.ts +66 -0
  52. package/dist/types/extensions/prebuilts/deploy-split.d.ts.map +1 -0
  53. package/dist/types/extensions/split/__generated__/Split/read/totalShares.d.ts +46 -0
  54. package/dist/types/extensions/split/__generated__/Split/read/totalShares.d.ts.map +1 -0
  55. package/dist/types/extensions/split/read/getAllRecipientsAddresses.d.ts +14 -0
  56. package/dist/types/extensions/split/read/getAllRecipientsAddresses.d.ts.map +1 -0
  57. package/dist/types/extensions/split/read/getAllRecipientsPercentages.d.ts +27 -0
  58. package/dist/types/extensions/split/read/getAllRecipientsPercentages.d.ts.map +1 -0
  59. package/dist/types/extensions/split/read/getRecipientSplitPercentage.d.ts +21 -0
  60. package/dist/types/extensions/split/read/getRecipientSplitPercentage.d.ts.map +1 -0
  61. package/dist/types/react/core/hooks/auth/useSiweAuth.d.ts.map +1 -1
  62. package/dist/types/react/core/hooks/others/useProfiles.d.ts +1 -1
  63. package/dist/types/version.d.ts +1 -1
  64. package/dist/types/version.d.ts.map +1 -1
  65. package/dist/types/wallets/in-app/core/wallet/profiles.d.ts +3 -3
  66. package/package.json +1 -1
  67. package/src/exports/deploys.ts +5 -0
  68. package/src/exports/extensions/split.ts +8 -0
  69. package/src/extensions/prebuilts/__generated__/Split/write/initialize.ts +191 -0
  70. package/src/extensions/prebuilts/deploy-split.test.ts +31 -0
  71. package/src/extensions/prebuilts/deploy-split.ts +144 -0
  72. package/src/extensions/split/__generated__/Split/read/totalShares.ts +72 -0
  73. package/src/extensions/split/read/getAllRecipientsAddresses.test.ts +39 -0
  74. package/src/extensions/split/read/getAllRecipientsAddresses.ts +26 -0
  75. package/src/extensions/split/read/getAllRecipientsPercentages.test.ts +48 -0
  76. package/src/extensions/split/read/getAllRecipientsPercentages.ts +41 -0
  77. package/src/extensions/split/read/getRecipientSplitPercentage.test.ts +45 -0
  78. package/src/extensions/split/read/getRecipientSplitPercentage.ts +40 -0
  79. package/src/react/core/hooks/auth/useSiweAuth.ts +7 -0
  80. package/src/react/core/hooks/others/useProfiles.ts +1 -1
  81. package/src/version.ts +1 -1
  82. package/src/wallets/in-app/core/wallet/profiles.ts +3 -3
@@ -0,0 +1,66 @@
1
+ import type { FileOrBufferOrString } from "../../storage/upload/types.js";
2
+ import type { Prettify } from "../../utils/type-utils.js";
3
+ import type { ClientAndChainAndAccount } from "../../utils/types.js";
4
+ /**
5
+ * @extension PREBUILT
6
+ */
7
+ export type SplitContractParams = {
8
+ name: string;
9
+ /**
10
+ * An array of strings containing wallet addresses of the recipients
11
+ * For example:
12
+ * ```ts
13
+ * ["0x...123", "0x...456"]
14
+ * ```
15
+ */
16
+ payees: string[];
17
+ /**
18
+ * An array of bigints containing the shared percentages of each respective payees.
19
+ * Must have the same length as `payees`
20
+ * @example
21
+ * ```ts
22
+ * [
23
+ * 5100n, // 51%
24
+ * 4900n, // 49%
25
+ * ]
26
+ * ```
27
+ */
28
+ shares: bigint[];
29
+ description?: string;
30
+ image?: FileOrBufferOrString;
31
+ external_link?: string;
32
+ social_urls?: Record<string, string>;
33
+ symbol?: string;
34
+ contractURI?: string;
35
+ defaultAdmin?: string;
36
+ trustedForwarders?: string[];
37
+ };
38
+ /**
39
+ * @extension DEPLOY
40
+ */
41
+ export type DeploySplitContractOptions = Prettify<ClientAndChainAndAccount & {
42
+ params: SplitContractParams;
43
+ }>;
44
+ /**
45
+ * Deploys a thirdweb [`Split contract`](https://thirdweb.com/thirdweb.eth/Split)
46
+ * On chains where the thirdweb infrastructure contracts are not deployed, this function will deploy them as well.
47
+ * @param options - The deployment options.
48
+ * @returns The deployed contract address.
49
+ * @extension DEPLOY
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * import { deploySplitContract } from "thirdweb/deploys";
54
+ * const contractAddress = await deploySplitContract({
55
+ * chain,
56
+ * client,
57
+ * account,
58
+ * params: {
59
+ * name: "Split contract",
60
+ * payees: ["0x...123", "0x...456"],
61
+ * shares: [5100, 4900], // See type `SplitContractParams` for more context
62
+ * });
63
+ * ```
64
+ */
65
+ export declare function deploySplitContract(options: DeploySplitContractOptions): Promise<string>;
66
+ //# sourceMappingURL=deploy-split.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-split.d.ts","sourceRoot":"","sources":["../../../../src/extensions/prebuilts/deploy-split.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGrE;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;;;;;;OAUG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAC/C,wBAAwB,GAAG;IACzB,MAAM,EAAE,mBAAmB,CAAC;CAC7B,CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,mBAwB5E"}
@@ -0,0 +1,46 @@
1
+ import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
2
+ import type { Hex } from "../../../../../utils/encoding/hex.js";
3
+ import type { ThirdwebContract } from "../../../../../contract/contract.js";
4
+ export declare const FN_SELECTOR: "0x3a98ef39";
5
+ /**
6
+ * Checks if the `totalShares` method is supported by the given contract.
7
+ * @param contract The ThirdwebContract.
8
+ * @returns A promise that resolves to a boolean indicating if the `totalShares` method is supported.
9
+ * @extension SPLIT
10
+ * @example
11
+ * ```ts
12
+ * import { isTotalSharesSupported } from "thirdweb/extensions/split";
13
+ *
14
+ * const supported = await isTotalSharesSupported(contract);
15
+ * ```
16
+ */
17
+ export declare function isTotalSharesSupported(contract: ThirdwebContract<any>): Promise<boolean>;
18
+ /**
19
+ * Decodes the result of the totalShares function call.
20
+ * @param result - The hexadecimal result to decode.
21
+ * @returns The decoded result as per the FN_OUTPUTS definition.
22
+ * @extension SPLIT
23
+ * @example
24
+ * ```ts
25
+ * import { decodeTotalSharesResult } from "thirdweb/extensions/split";
26
+ * const result = decodeTotalSharesResult("...");
27
+ * ```
28
+ */
29
+ export declare function decodeTotalSharesResult(result: Hex): bigint;
30
+ /**
31
+ * Calls the "totalShares" function on the contract.
32
+ * @param options - The options for the totalShares function.
33
+ * @returns The parsed result of the function call.
34
+ * @extension SPLIT
35
+ * @example
36
+ * ```ts
37
+ * import { totalShares } from "thirdweb/extensions/split";
38
+ *
39
+ * const result = await totalShares({
40
+ * contract,
41
+ * });
42
+ *
43
+ * ```
44
+ */
45
+ export declare function totalShares(options: BaseTransactionOptions): Promise<bigint>;
46
+ //# sourceMappingURL=totalShares.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"totalShares.d.ts","sourceRoot":"","sources":["../../../../../../../src/extensions/split/__generated__/Split/read/totalShares.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAG5E,eAAO,MAAM,WAAW,cAAwB,CAAC;AAQjD;;;;;;;;;;;GAWG;AACH,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,oBAK3E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,GAAG,UAElD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,sBAAsB,mBAMhE"}
@@ -0,0 +1,14 @@
1
+ import type { BaseTransactionOptions } from "../../../transaction/types.js";
2
+ /**
3
+ * Get the addresses of all recipients of a [`thirdweb Split contract`](https://thirdweb.com/thirdweb.eth/Split)
4
+ * @extension SPLIT
5
+ * @returns an array of wallet addresses
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { getAllRecipientsAddresses } from "thirdweb/extensions/split";
10
+ *
11
+ * const addresses = await getAllRecipientsAddresses({ contract });
12
+ */
13
+ export declare function getAllRecipientsAddresses(options: BaseTransactionOptions): Promise<string[]>;
14
+ //# sourceMappingURL=getAllRecipientsAddresses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllRecipientsAddresses.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/split/read/getAllRecipientsAddresses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAI5E;;;;;;;;;;GAUG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB"}
@@ -0,0 +1,27 @@
1
+ import type { BaseTransactionOptions } from "../../../transaction/types.js";
2
+ import { type SplitRecipient } from "./getRecipientSplitPercentage.js";
3
+ /**
4
+ * Get all the recipients of a Split contracts
5
+ * @extension SPLIT
6
+ * @returns an array of recipients' addresses and split percentage of each
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { getAllRecipientsPercentages } from "thirdweb/extensions/split";
11
+ *
12
+ * const allRecipients = await getAllRecipientsPercentages({ contract });
13
+ * // Example result:
14
+ * [
15
+ * {
16
+ * address: "0x1...",
17
+ * splitPercentage: 25, // 25%
18
+ * },
19
+ * {
20
+ * address: "0x2...",
21
+ * splitPercentage: 75, // 75%
22
+ * },
23
+ * ];
24
+ * ```
25
+ */
26
+ export declare function getAllRecipientsPercentages(options: BaseTransactionOptions): Promise<SplitRecipient[]>;
27
+ //# sourceMappingURL=getAllRecipientsPercentages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllRecipientsPercentages.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/split/read/getAllRecipientsPercentages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,cAAc,EAAE,CAAC,CAQ3B"}
@@ -0,0 +1,21 @@
1
+ import type { BaseTransactionOptions } from "../../../transaction/types.js";
2
+ /**
3
+ * @extension SPLIT
4
+ */
5
+ export interface SplitRecipient {
6
+ /**
7
+ * The address of the recipient
8
+ */
9
+ address: string;
10
+ /**
11
+ * The split of the recipient as a percentage of the total amount
12
+ *
13
+ * I.e. If a recipient has a split of 50%, and the asset sells for 100 ETH,
14
+ * the recipient will receive 50 ETH.
15
+ */
16
+ splitPercentage: number;
17
+ }
18
+ export declare function getRecipientSplitPercentage(options: BaseTransactionOptions<{
19
+ recipientAddress: string;
20
+ }>): Promise<SplitRecipient>;
21
+ //# sourceMappingURL=getRecipientSplitPercentage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRecipientSplitPercentage.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/split/read/getRecipientSplitPercentage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAI5E;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,sBAAsB,CAAC;IAAE,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAAC,GAC5D,OAAO,CAAC,cAAc,CAAC,CAezB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useSiweAuth.d.ts","sourceRoot":"","sources":["../../../../../../src/react/core/hooks/auth/useSiweAuth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAEhF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAG5B;;;OAGG;IACH,eAAe,EAAE,CAAC,MAAM,EAAE;QACxB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAI5B;;;OAGG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,wBAAwB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAI7D;;OAEG;IACH,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAI9B;;;OAGG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,wBAAgB,WAAW,CACzB,YAAY,CAAC,EAAE,MAAM,EACrB,aAAa,CAAC,EAAE,OAAO,EACvB,WAAW,CAAC,EAAE,eAAe;;;;;;;;EA4F9B"}
1
+ {"version":3,"file":"useSiweAuth.d.ts","sourceRoot":"","sources":["../../../../../../src/react/core/hooks/auth/useSiweAuth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAE9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAEhF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAG5B;;;OAGG;IACH,eAAe,EAAE,CAAC,MAAM,EAAE;QACxB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAI5B;;;OAGG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,wBAAwB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAI7D;;OAEG;IACH,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAI9B;;;OAGG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,wBAAgB,WAAW,CACzB,YAAY,CAAC,EAAE,MAAM,EACrB,aAAa,CAAC,EAAE,OAAO,EACvB,WAAW,CAAC,EAAE,eAAe;;;;;;;;EAkG9B"}
@@ -1,7 +1,7 @@
1
1
  import { type UseQueryResult } from "@tanstack/react-query";
2
2
  import type { Profile } from "../../../../wallets/in-app/core/authentication/types.js";
3
3
  /**
4
- * @description Retrieves all linked profiles for the current wallet.
4
+ * Retrieves all linked profiles for the current wallet.
5
5
  *
6
6
  * @returns A React Query result containing the linked profiles for the connected in-app wallet.
7
7
  *
@@ -1,2 +1,2 @@
1
- export declare const version = "5.45.1";
1
+ export declare const version = "5.45.2-nightly-b15aa4cdff3f3b233025da285780668a18fe29ab-20240813000336";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,2EAA2E,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import type { Wallet } from "../../../interfaces/wallet.js";
2
2
  import type { MultiStepAuthArgsType, Profile, SingleStepAuthArgsType } from "../authentication/types.js";
3
3
  /**
4
- * @description
5
4
  * Gets the linked profiles for the provided wallet.
6
5
  * This method is only available for in-app wallets.
7
6
  *
@@ -19,13 +18,13 @@ import type { MultiStepAuthArgsType, Profile, SingleStepAuthArgsType } from "../
19
18
  * console.log(profiles[0].type);
20
19
  * console.log(profiles[0].details.email);
21
20
  * ```
21
+ * @wallet
22
22
  */
23
23
  export declare function getProfiles(wallet: Wallet<"inApp">): Promise<Profile[]>;
24
24
  /**
25
- * @description
26
25
  * Connects a new profile (authentication method) to the current user.
27
26
  * The connected profile can be any valid in-app wallet including email, phone, passkey, etc.
28
- * The inputs mirror those used when authenticating normally, @see {@link Wallet.connect}
27
+ * The inputs mirror those used when authenticating normally.
29
28
  *
30
29
  * **When a profile is linked to the account, that profile can then be used to sign into the account.**
31
30
  *
@@ -43,6 +42,7 @@ export declare function getProfiles(wallet: Wallet<"inApp">): Promise<Profile[]>
43
42
  * await wallet.connect({ strategy: "google" });
44
43
  * const profiles = await linkProfile(wallet, { strategy: "discord" });
45
44
  * ```
45
+ * @wallet
46
46
  */
47
47
  export declare function linkProfile(wallet: Wallet<"inApp">, auth: MultiStepAuthArgsType | SingleStepAuthArgsType): Promise<Profile[]>;
48
48
  //# sourceMappingURL=profiles.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thirdweb",
3
- "version": "5.45.1",
3
+ "version": "5.45.2-nightly-b15aa4cdff3f3b233025da285780668a18fe29ab-20240813000336",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/thirdweb-dev/js.git#main"
@@ -33,3 +33,8 @@ export {
33
33
  type PrepareDirectDeployTransactionOptions,
34
34
  } from "../contract/deployment/deploy-with-abi.js";
35
35
  export { computePublishedContractAddress } from "../utils/any-evm/compute-published-contract-address.js";
36
+ export {
37
+ deploySplitContract,
38
+ type SplitContractParams,
39
+ type DeploySplitContractOptions,
40
+ } from "../extensions/prebuilts/deploy-split.js";
@@ -34,6 +34,14 @@ export { totalReleased } from "../../extensions/split/__generated__/Split/read/t
34
34
 
35
35
  export { totalReleasedByToken } from "../../extensions/split/read/totalReleasedByToken.js";
36
36
 
37
+ export { getAllRecipientsAddresses } from "../../extensions/split/read/getAllRecipientsAddresses.js";
38
+
39
+ export { getAllRecipientsPercentages } from "../../extensions/split/read/getAllRecipientsPercentages.js";
40
+
41
+ export {
42
+ getRecipientSplitPercentage,
43
+ type SplitRecipient,
44
+ } from "../../extensions/split/read/getRecipientSplitPercentage.js";
37
45
  /**
38
46
  * WRITE
39
47
  */
@@ -0,0 +1,191 @@
1
+ import type { AbiParameterToPrimitiveType } from "abitype";
2
+ import type {
3
+ BaseTransactionOptions,
4
+ WithOverrides,
5
+ } from "../../../../../transaction/types.js";
6
+ import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
7
+ import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
8
+ import { once } from "../../../../../utils/promise/once.js";
9
+ import type { ThirdwebContract } from "../../../../../contract/contract.js";
10
+ import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
11
+
12
+ /**
13
+ * Represents the parameters for the "initialize" function.
14
+ */
15
+ export type InitializeParams = WithOverrides<{
16
+ defaultAdmin: AbiParameterToPrimitiveType<{
17
+ type: "address";
18
+ name: "_defaultAdmin";
19
+ }>;
20
+ contractURI: AbiParameterToPrimitiveType<{
21
+ type: "string";
22
+ name: "_contractURI";
23
+ }>;
24
+ trustedForwarders: AbiParameterToPrimitiveType<{
25
+ type: "address[]";
26
+ name: "_trustedForwarders";
27
+ }>;
28
+ payees: AbiParameterToPrimitiveType<{ type: "address[]"; name: "_payees" }>;
29
+ shares: AbiParameterToPrimitiveType<{ type: "uint256[]"; name: "_shares" }>;
30
+ }>;
31
+
32
+ export const FN_SELECTOR = "0xb1a14437" as const;
33
+ const FN_INPUTS = [
34
+ {
35
+ type: "address",
36
+ name: "_defaultAdmin",
37
+ },
38
+ {
39
+ type: "string",
40
+ name: "_contractURI",
41
+ },
42
+ {
43
+ type: "address[]",
44
+ name: "_trustedForwarders",
45
+ },
46
+ {
47
+ type: "address[]",
48
+ name: "_payees",
49
+ },
50
+ {
51
+ type: "uint256[]",
52
+ name: "_shares",
53
+ },
54
+ ] as const;
55
+ const FN_OUTPUTS = [] as const;
56
+
57
+ /**
58
+ * Checks if the `initialize` method is supported by the given contract.
59
+ * @param contract The ThirdwebContract.
60
+ * @returns A promise that resolves to a boolean indicating if the `initialize` method is supported.
61
+ * @extension PREBUILTS
62
+ * @example
63
+ * ```ts
64
+ * import { isInitializeSupported } from "thirdweb/extensions/prebuilts";
65
+ *
66
+ * const supported = await isInitializeSupported(contract);
67
+ * ```
68
+ */
69
+ export async function isInitializeSupported(contract: ThirdwebContract<any>) {
70
+ return detectMethod({
71
+ contract,
72
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
73
+ });
74
+ }
75
+
76
+ /**
77
+ * Encodes the parameters for the "initialize" function.
78
+ * @param options - The options for the initialize function.
79
+ * @returns The encoded ABI parameters.
80
+ * @extension PREBUILTS
81
+ * @example
82
+ * ```ts
83
+ * import { encodeInitializeParams } "thirdweb/extensions/prebuilts";
84
+ * const result = encodeInitializeParams({
85
+ * defaultAdmin: ...,
86
+ * contractURI: ...,
87
+ * trustedForwarders: ...,
88
+ * payees: ...,
89
+ * shares: ...,
90
+ * });
91
+ * ```
92
+ */
93
+ export function encodeInitializeParams(options: InitializeParams) {
94
+ return encodeAbiParameters(FN_INPUTS, [
95
+ options.defaultAdmin,
96
+ options.contractURI,
97
+ options.trustedForwarders,
98
+ options.payees,
99
+ options.shares,
100
+ ]);
101
+ }
102
+
103
+ /**
104
+ * Encodes the "initialize" function into a Hex string with its parameters.
105
+ * @param options - The options for the initialize function.
106
+ * @returns The encoded hexadecimal string.
107
+ * @extension PREBUILTS
108
+ * @example
109
+ * ```ts
110
+ * import { encodeInitialize } "thirdweb/extensions/prebuilts";
111
+ * const result = encodeInitialize({
112
+ * defaultAdmin: ...,
113
+ * contractURI: ...,
114
+ * trustedForwarders: ...,
115
+ * payees: ...,
116
+ * shares: ...,
117
+ * });
118
+ * ```
119
+ */
120
+ export function encodeInitialize(options: InitializeParams) {
121
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
122
+ // we can do this because we know the specific formats of the values
123
+ return (FN_SELECTOR +
124
+ encodeInitializeParams(options).slice(
125
+ 2,
126
+ )) as `${typeof FN_SELECTOR}${string}`;
127
+ }
128
+
129
+ /**
130
+ * Prepares a transaction to call the "initialize" function on the contract.
131
+ * @param options - The options for the "initialize" function.
132
+ * @returns A prepared transaction object.
133
+ * @extension PREBUILTS
134
+ * @example
135
+ * ```ts
136
+ * import { initialize } from "thirdweb/extensions/prebuilts";
137
+ *
138
+ * const transaction = initialize({
139
+ * contract,
140
+ * defaultAdmin: ...,
141
+ * contractURI: ...,
142
+ * trustedForwarders: ...,
143
+ * payees: ...,
144
+ * shares: ...,
145
+ * overrides: {
146
+ * ...
147
+ * }
148
+ * });
149
+ *
150
+ * // Send the transaction
151
+ * ...
152
+ *
153
+ * ```
154
+ */
155
+ export function initialize(
156
+ options: BaseTransactionOptions<
157
+ | InitializeParams
158
+ | {
159
+ asyncParams: () => Promise<InitializeParams>;
160
+ }
161
+ >,
162
+ ) {
163
+ const asyncOptions = once(async () => {
164
+ return "asyncParams" in options ? await options.asyncParams() : options;
165
+ });
166
+
167
+ return prepareContractCall({
168
+ contract: options.contract,
169
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
170
+ params: async () => {
171
+ const resolvedOptions = await asyncOptions();
172
+ return [
173
+ resolvedOptions.defaultAdmin,
174
+ resolvedOptions.contractURI,
175
+ resolvedOptions.trustedForwarders,
176
+ resolvedOptions.payees,
177
+ resolvedOptions.shares,
178
+ ] as const;
179
+ },
180
+ value: async () => (await asyncOptions()).overrides?.value,
181
+ accessList: async () => (await asyncOptions()).overrides?.accessList,
182
+ gas: async () => (await asyncOptions()).overrides?.gas,
183
+ gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
184
+ maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
185
+ maxPriorityFeePerGas: async () =>
186
+ (await asyncOptions()).overrides?.maxPriorityFeePerGas,
187
+ nonce: async () => (await asyncOptions()).overrides?.nonce,
188
+ extraGas: async () => (await asyncOptions()).overrides?.extraGas,
189
+ erc20Value: async () => (await asyncOptions()).overrides?.erc20Value,
190
+ });
191
+ }
@@ -0,0 +1,31 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { ANVIL_CHAIN } from "~test/chains.js";
3
+ import { TEST_CLIENT } from "~test/test-clients.js";
4
+ import { TEST_ACCOUNT_A } from "~test/test-wallets.js";
5
+ import { isAddress } from "../../utils/address.js";
6
+ import { deploySplitContract } from "./deploy-split.js";
7
+
8
+ describe("deploy-split contract", () => {
9
+ it("should deploy Split contract", async () => {
10
+ const address = await deploySplitContract({
11
+ account: TEST_ACCOUNT_A,
12
+ client: TEST_CLIENT,
13
+ chain: ANVIL_CHAIN,
14
+ params: {
15
+ name: "split-contract",
16
+ payees: [
17
+ "0x12345674b599ce99958242b3D3741e7b01841DF3",
18
+ "0xA6f11e47dE28B3dB934e945daeb6F538E9019694",
19
+ ],
20
+ shares: [
21
+ 5100n, // 51%
22
+ 4900n, // 49%
23
+ ],
24
+ },
25
+ });
26
+ expect(address).toBeDefined();
27
+ expect(isAddress(address)).toBe(true);
28
+ // Further tests to verify the functionality of this contract
29
+ // are done in other Split tests
30
+ });
31
+ });
@@ -0,0 +1,144 @@
1
+ import type { ThirdwebClient } from "../../client/client.js";
2
+ import type { ThirdwebContract } from "../../contract/contract.js";
3
+ import { deployViaAutoFactory } from "../../contract/deployment/deploy-via-autofactory.js";
4
+ import { getOrDeployInfraForPublishedContract } from "../../contract/deployment/utils/bootstrap.js";
5
+ import { upload } from "../../storage/upload.js";
6
+ import type { FileOrBufferOrString } from "../../storage/upload/types.js";
7
+ import type { Prettify } from "../../utils/type-utils.js";
8
+ import type { ClientAndChainAndAccount } from "../../utils/types.js";
9
+ import { initialize } from "./__generated__/Split/write/initialize.js";
10
+
11
+ /**
12
+ * @extension PREBUILT
13
+ */
14
+ export type SplitContractParams = {
15
+ name: string;
16
+
17
+ /**
18
+ * An array of strings containing wallet addresses of the recipients
19
+ * For example:
20
+ * ```ts
21
+ * ["0x...123", "0x...456"]
22
+ * ```
23
+ */
24
+ payees: string[];
25
+ /**
26
+ * An array of bigints containing the shared percentages of each respective payees.
27
+ * Must have the same length as `payees`
28
+ * @example
29
+ * ```ts
30
+ * [
31
+ * 5100n, // 51%
32
+ * 4900n, // 49%
33
+ * ]
34
+ * ```
35
+ */
36
+ shares: bigint[];
37
+ description?: string;
38
+ image?: FileOrBufferOrString;
39
+ external_link?: string;
40
+ social_urls?: Record<string, string>;
41
+ symbol?: string;
42
+ contractURI?: string;
43
+ defaultAdmin?: string;
44
+ trustedForwarders?: string[];
45
+ };
46
+
47
+ /**
48
+ * @extension DEPLOY
49
+ */
50
+ export type DeploySplitContractOptions = Prettify<
51
+ ClientAndChainAndAccount & {
52
+ params: SplitContractParams;
53
+ }
54
+ >;
55
+
56
+ /**
57
+ * Deploys a thirdweb [`Split contract`](https://thirdweb.com/thirdweb.eth/Split)
58
+ * On chains where the thirdweb infrastructure contracts are not deployed, this function will deploy them as well.
59
+ * @param options - The deployment options.
60
+ * @returns The deployed contract address.
61
+ * @extension DEPLOY
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { deploySplitContract } from "thirdweb/deploys";
66
+ * const contractAddress = await deploySplitContract({
67
+ * chain,
68
+ * client,
69
+ * account,
70
+ * params: {
71
+ * name: "Split contract",
72
+ * payees: ["0x...123", "0x...456"],
73
+ * shares: [5100, 4900], // See type `SplitContractParams` for more context
74
+ * });
75
+ * ```
76
+ */
77
+ export async function deploySplitContract(options: DeploySplitContractOptions) {
78
+ const { chain, client, account, params } = options;
79
+ const { cloneFactoryContract, implementationContract } =
80
+ await getOrDeployInfraForPublishedContract({
81
+ chain,
82
+ client,
83
+ account,
84
+ contractId: "Split",
85
+ constructorParams: [],
86
+ });
87
+ const initializeTransaction = await getInitializeTransaction({
88
+ client,
89
+ implementationContract,
90
+ params,
91
+ accountAddress: account.address,
92
+ });
93
+
94
+ return deployViaAutoFactory({
95
+ client,
96
+ chain,
97
+ account,
98
+ cloneFactoryContract,
99
+ initializeTransaction,
100
+ });
101
+ }
102
+
103
+ async function getInitializeTransaction(options: {
104
+ client: ThirdwebClient;
105
+ implementationContract: ThirdwebContract;
106
+ params: SplitContractParams;
107
+ accountAddress: string;
108
+ }) {
109
+ const { client, implementationContract, params, accountAddress } = options;
110
+ const {
111
+ name,
112
+ description,
113
+ symbol,
114
+ image,
115
+ external_link,
116
+ social_urls,
117
+ payees,
118
+ shares,
119
+ } = params;
120
+ const contractURI =
121
+ params.contractURI ||
122
+ (await upload({
123
+ client,
124
+ files: [
125
+ {
126
+ name,
127
+ description,
128
+ symbol,
129
+ image,
130
+ external_link,
131
+ social_urls,
132
+ },
133
+ ],
134
+ })) ||
135
+ "";
136
+ return initialize({
137
+ contract: implementationContract,
138
+ defaultAdmin: params.defaultAdmin || accountAddress,
139
+ contractURI,
140
+ trustedForwarders: params.trustedForwarders || [],
141
+ payees,
142
+ shares,
143
+ });
144
+ }