thirdweb 5.105.34 → 5.105.35

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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInitBytecodeWithSalt = exports.SaltFlag = exports.generateSalt = exports.isPoolRouterEnabled = exports.getDeployedEntrypointERC20 = exports.getDeployedContractFactory = exports.distributeToken = exports.createToken = exports.DEFAULT_DEVELOPER_REWARD_BPS = exports.DEFAULT_DEVELOPER_ADDRESS = exports.positionManager = exports.position = exports.claimRewards = exports.getRewards = void 0;
3
+ exports.getInitBytecodeWithSalt = exports.SaltFlag = exports.generateSalt = exports.predictAddress = exports.isPoolRouterEnabled = exports.getDeployedEntrypointERC20 = exports.getDeployedContractFactory = exports.distributeToken = exports.createToken = exports.DEFAULT_DEVELOPER_REWARD_BPS = exports.DEFAULT_DEVELOPER_ADDRESS = exports.positionManager = exports.position = exports.claimRewards = exports.getRewards = void 0;
4
4
  var getRewards_js_1 = require("../extensions/tokens/__generated__/ERC20Entrypoint/read/getRewards.js");
5
5
  Object.defineProperty(exports, "getRewards", { enumerable: true, get: function () { return getRewards_js_1.getRewards; } });
6
6
  var claimRewards_js_1 = require("../extensions/tokens/__generated__/ERC20Entrypoint/write/claimRewards.js");
@@ -21,6 +21,8 @@ Object.defineProperty(exports, "getDeployedContractFactory", { enumerable: true,
21
21
  Object.defineProperty(exports, "getDeployedEntrypointERC20", { enumerable: true, get: function () { return get_entrypoint_erc20_js_1.getDeployedEntrypointERC20; } });
22
22
  var is_router_enabled_js_1 = require("../tokens/is-router-enabled.js");
23
23
  Object.defineProperty(exports, "isPoolRouterEnabled", { enumerable: true, get: function () { return is_router_enabled_js_1.isPoolRouterEnabled; } });
24
+ var predict_address_js_1 = require("../tokens/predict-address.js");
25
+ Object.defineProperty(exports, "predictAddress", { enumerable: true, get: function () { return predict_address_js_1.predictAddress; } });
24
26
  var token_utils_js_1 = require("../tokens/token-utils.js");
25
27
  Object.defineProperty(exports, "generateSalt", { enumerable: true, get: function () { return token_utils_js_1.generateSalt; } });
26
28
  Object.defineProperty(exports, "SaltFlag", { enumerable: true, get: function () { return token_utils_js_1.SaltFlag; } });
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/exports/tokens.ts"],"names":[],"mappings":";;;AAAA,uGAAmG;AAA1F,2GAAA,UAAU,OAAA;AACnB,4GAAwG;AAA/F,+GAAA,YAAY,OAAA;AACrB,gGAA4F;AAAnF,uGAAA,QAAQ,OAAA;AACjB,8GAA0G;AAAjG,qHAAA,eAAe,OAAA;AACxB,uDAGgC;AAF9B,yHAAA,yBAAyB,OAAA;AACzB,4HAAA,4BAA4B,OAAA;AAE9B,6DAAwD;AAA/C,8GAAA,WAAW,OAAA;AACpB,qEAAgE;AAAvD,sHAAA,eAAe,OAAA;AACxB,6EAG2C;AAFzC,qIAAA,0BAA0B,OAAA;AAC1B,qIAAA,0BAA0B,OAAA;AAE5B,uEAAqE;AAA5D,2HAAA,mBAAmB,OAAA;AAC5B,2DAIkC;AAHhC,8GAAA,YAAY,OAAA;AACZ,0GAAA,QAAQ,OAAA;AAUV,kGAA0F;AAAjF,yIAAA,uBAAuB,OAAA"}
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/exports/tokens.ts"],"names":[],"mappings":";;;AAAA,uGAAmG;AAA1F,2GAAA,UAAU,OAAA;AACnB,4GAAwG;AAA/F,+GAAA,YAAY,OAAA;AACrB,gGAA4F;AAAnF,uGAAA,QAAQ,OAAA;AACjB,8GAA0G;AAAjG,qHAAA,eAAe,OAAA;AACxB,uDAGgC;AAF9B,yHAAA,yBAAyB,OAAA;AACzB,4HAAA,4BAA4B,OAAA;AAE9B,6DAAwD;AAA/C,8GAAA,WAAW,OAAA;AACpB,qEAAgE;AAAvD,sHAAA,eAAe,OAAA;AACxB,6EAG2C;AAFzC,qIAAA,0BAA0B,OAAA;AAC1B,qIAAA,0BAA0B,OAAA;AAE5B,uEAAqE;AAA5D,2HAAA,mBAAmB,OAAA;AAC5B,mEAA8D;AAArD,oHAAA,cAAc,OAAA;AACvB,2DAIkC;AAHhC,8GAAA,YAAY,OAAA;AACZ,0GAAA,QAAQ,OAAA;AAUV,kGAA0F;AAAjF,yIAAA,uBAAuB,OAAA"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.predictAddress = predictAddress;
4
+ const utils_1 = require("@noble/hashes/utils");
5
+ const predictAddress_js_1 = require("../extensions/tokens/__generated__/ERC20Entrypoint/read/predictAddress.js");
6
+ const hex_js_1 = require("../utils/encoding/hex.js");
7
+ const constants_js_1 = require("./constants.js");
8
+ const get_entrypoint_erc20_js_1 = require("./get-entrypoint-erc20.js");
9
+ const token_utils_js_1 = require("./token-utils.js");
10
+ async function predictAddress(options) {
11
+ const { client, account, params, launchConfig } = options;
12
+ const creator = params.owner || account.address;
13
+ const encodedInitData = await (0, token_utils_js_1.encodeInitParams)({
14
+ client,
15
+ creator,
16
+ params,
17
+ });
18
+ const salt = (0, token_utils_js_1.generateSalt)(options.salt || (0, utils_1.bytesToHex)((0, utils_1.randomBytes)(31)));
19
+ const entrypoint = await (0, get_entrypoint_erc20_js_1.getDeployedEntrypointERC20)(options);
20
+ let hookData = "0x";
21
+ let contractId = (0, hex_js_1.padHex)((0, hex_js_1.toHex)("ERC20Asset"), { size: 32 });
22
+ if (launchConfig?.kind === "pool") {
23
+ hookData = (0, token_utils_js_1.encodePoolConfig)(launchConfig.config);
24
+ contractId = (0, hex_js_1.padHex)((0, hex_js_1.toHex)("ERC20Asset_Pool"), { size: 32 });
25
+ }
26
+ const address = await (0, predictAddress_js_1.predictAddress)({
27
+ contract: entrypoint,
28
+ contractId,
29
+ params: {
30
+ data: encodedInitData,
31
+ hookData,
32
+ developer: options.developerAddress || constants_js_1.DEFAULT_DEVELOPER_ADDRESS,
33
+ salt,
34
+ },
35
+ creator,
36
+ });
37
+ return address;
38
+ }
39
+ //# sourceMappingURL=predict-address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"predict-address.js","sourceRoot":"","sources":["../../../src/tokens/predict-address.ts"],"names":[],"mappings":";;AAaA,wCAkCC;AA/CD,+CAA8D;AAE9D,iHAA8H;AAC9H,qDAAyD;AACzD,iDAA2D;AAC3D,uEAAuE;AACvE,qDAI0B;AAGnB,KAAK,UAAU,cAAc,CAAC,OAA2B;IAC9D,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE1D,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAChD,MAAM,eAAe,GAAG,MAAM,IAAA,iCAAgB,EAAC;QAC7C,MAAM;QACN,OAAO;QACP,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,IAAI,GAAQ,IAAA,6BAAY,EAAC,OAAO,CAAC,IAAI,IAAI,IAAA,kBAAU,EAAC,IAAA,mBAAW,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAE5E,MAAM,UAAU,GAAG,MAAM,IAAA,oDAA0B,EAAC,OAAO,CAAC,CAAC;IAE7D,IAAI,QAAQ,GAAQ,IAAI,CAAC;IACzB,IAAI,UAAU,GAAG,IAAA,eAAM,EAAC,IAAA,cAAK,EAAC,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3D,IAAI,YAAY,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;QAClC,QAAQ,GAAG,IAAA,iCAAgB,EAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACjD,UAAU,GAAG,IAAA,eAAM,EAAC,IAAA,cAAK,EAAC,iBAAiB,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,IAAA,kCAAe,EAAC;QACpC,QAAQ,EAAE,UAAU;QACpB,UAAU;QACV,MAAM,EAAE;YACN,IAAI,EAAE,eAAe;YACrB,QAAQ;YACR,SAAS,EAAE,OAAO,CAAC,gBAAgB,IAAI,wCAAyB;YAChE,IAAI;SACL;QACD,OAAO;KACR,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = "5.105.34";
4
+ exports.version = "5.105.35";
5
5
  //# sourceMappingURL=version.js.map
@@ -7,6 +7,7 @@ export { createToken } from "../tokens/create-token.js";
7
7
  export { distributeToken } from "../tokens/distribute-token.js";
8
8
  export { getDeployedContractFactory, getDeployedEntrypointERC20, } from "../tokens/get-entrypoint-erc20.js";
9
9
  export { isPoolRouterEnabled } from "../tokens/is-router-enabled.js";
10
+ export { predictAddress } from "../tokens/predict-address.js";
10
11
  export { generateSalt, SaltFlag, } from "../tokens/token-utils.js";
11
12
  export { getInitBytecodeWithSalt } from "../utils/any-evm/get-init-bytecode-with-salt.js";
12
13
  //# sourceMappingURL=tokens.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/exports/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uEAAuE,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,0EAA0E,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,MAAM,kEAAkE,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,yEAAyE,CAAC;AAC1G,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,QAAQ,GAET,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC"}
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/exports/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uEAAuE,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,0EAA0E,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,MAAM,kEAAkE,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,yEAAyE,CAAC;AAC1G,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EACL,YAAY,EACZ,QAAQ,GAET,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { bytesToHex, randomBytes } from "@noble/hashes/utils";
2
+ import { predictAddress as _predictAddress } from "../extensions/tokens/__generated__/ERC20Entrypoint/read/predictAddress.js";
3
+ import { padHex, toHex } from "../utils/encoding/hex.js";
4
+ import { DEFAULT_DEVELOPER_ADDRESS } from "./constants.js";
5
+ import { getDeployedEntrypointERC20 } from "./get-entrypoint-erc20.js";
6
+ import { encodeInitParams, encodePoolConfig, generateSalt, } from "./token-utils.js";
7
+ export async function predictAddress(options) {
8
+ const { client, account, params, launchConfig } = options;
9
+ const creator = params.owner || account.address;
10
+ const encodedInitData = await encodeInitParams({
11
+ client,
12
+ creator,
13
+ params,
14
+ });
15
+ const salt = generateSalt(options.salt || bytesToHex(randomBytes(31)));
16
+ const entrypoint = await getDeployedEntrypointERC20(options);
17
+ let hookData = "0x";
18
+ let contractId = padHex(toHex("ERC20Asset"), { size: 32 });
19
+ if (launchConfig?.kind === "pool") {
20
+ hookData = encodePoolConfig(launchConfig.config);
21
+ contractId = padHex(toHex("ERC20Asset_Pool"), { size: 32 });
22
+ }
23
+ const address = await _predictAddress({
24
+ contract: entrypoint,
25
+ contractId,
26
+ params: {
27
+ data: encodedInitData,
28
+ hookData,
29
+ developer: options.developerAddress || DEFAULT_DEVELOPER_ADDRESS,
30
+ salt,
31
+ },
32
+ creator,
33
+ });
34
+ return address;
35
+ }
36
+ //# sourceMappingURL=predict-address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"predict-address.js","sourceRoot":"","sources":["../../../src/tokens/predict-address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM,2EAA2E,CAAC;AAC9H,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAG1B,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAA2B;IAC9D,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE1D,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAChD,MAAM,eAAe,GAAG,MAAM,gBAAgB,CAAC;QAC7C,MAAM;QACN,OAAO;QACP,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,IAAI,GAAQ,YAAY,CAAC,OAAO,CAAC,IAAI,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAE5E,MAAM,UAAU,GAAG,MAAM,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAE7D,IAAI,QAAQ,GAAQ,IAAI,CAAC;IACzB,IAAI,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3D,IAAI,YAAY,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;QAClC,QAAQ,GAAG,gBAAgB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACjD,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACpC,QAAQ,EAAE,UAAU;QACpB,UAAU;QACV,MAAM,EAAE;YACN,IAAI,EAAE,eAAe;YACrB,QAAQ;YACR,SAAS,EAAE,OAAO,CAAC,gBAAgB,IAAI,yBAAyB;YAChE,IAAI;SACL;QACD,OAAO;KACR,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,2 +1,2 @@
1
- export const version = "5.105.34";
1
+ export const version = "5.105.35";
2
2
  //# sourceMappingURL=version.js.map
@@ -7,6 +7,7 @@ export { createToken } from "../tokens/create-token.js";
7
7
  export { distributeToken } from "../tokens/distribute-token.js";
8
8
  export { getDeployedContractFactory, getDeployedEntrypointERC20, } from "../tokens/get-entrypoint-erc20.js";
9
9
  export { isPoolRouterEnabled } from "../tokens/is-router-enabled.js";
10
+ export { predictAddress } from "../tokens/predict-address.js";
10
11
  export { generateSalt, SaltFlag, type SaltFlagType, } from "../tokens/token-utils.js";
11
12
  export type { CreateTokenByImplementationConfigOptions, CreateTokenOptions, DistributeContent, PoolConfig, TokenParams, } from "../tokens/types.js";
12
13
  export { getInitBytecodeWithSalt } from "../utils/any-evm/get-init-bytecode-with-salt.js";
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/exports/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uEAAuE,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,0EAA0E,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,MAAM,kEAAkE,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,yEAAyE,CAAC;AAC1G,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,KAAK,YAAY,GAClB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,wCAAwC,EACxC,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC"}
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/exports/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uEAAuE,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,0EAA0E,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,MAAM,kEAAkE,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,yEAAyE,CAAC;AAC1G,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,KAAK,YAAY,GAClB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,wCAAwC,EACxC,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CreateTokenOptions } from "./types.js";
2
+ export declare function predictAddress(options: CreateTokenOptions): Promise<string>;
3
+ //# sourceMappingURL=predict-address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"predict-address.d.ts","sourceRoot":"","sources":["../../../src/tokens/predict-address.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,mBAkC/D"}
@@ -1,2 +1,2 @@
1
- export declare const version = "5.105.34";
1
+ export declare const version = "5.105.35";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -388,7 +388,7 @@
388
388
  }
389
389
  },
390
390
  "typings": "./dist/types/exports/thirdweb.d.ts",
391
- "version": "5.105.34",
391
+ "version": "5.105.35",
392
392
  "scripts": {
393
393
  "bench": "vitest -c ./test/vitest.config.ts bench",
394
394
  "bench:compare": "bun run ./benchmarks/run.ts",
@@ -13,6 +13,7 @@ export {
13
13
  getDeployedEntrypointERC20,
14
14
  } from "../tokens/get-entrypoint-erc20.js";
15
15
  export { isPoolRouterEnabled } from "../tokens/is-router-enabled.js";
16
+ export { predictAddress } from "../tokens/predict-address.js";
16
17
  export {
17
18
  generateSalt,
18
19
  SaltFlag,
@@ -0,0 +1,48 @@
1
+ import { bytesToHex, randomBytes } from "@noble/hashes/utils";
2
+ import type { Hex } from "viem";
3
+ import { predictAddress as _predictAddress } from "../extensions/tokens/__generated__/ERC20Entrypoint/read/predictAddress.js";
4
+ import { padHex, toHex } from "../utils/encoding/hex.js";
5
+ import { DEFAULT_DEVELOPER_ADDRESS } from "./constants.js";
6
+ import { getDeployedEntrypointERC20 } from "./get-entrypoint-erc20.js";
7
+ import {
8
+ encodeInitParams,
9
+ encodePoolConfig,
10
+ generateSalt,
11
+ } from "./token-utils.js";
12
+ import type { CreateTokenOptions } from "./types.js";
13
+
14
+ export async function predictAddress(options: CreateTokenOptions) {
15
+ const { client, account, params, launchConfig } = options;
16
+
17
+ const creator = params.owner || account.address;
18
+ const encodedInitData = await encodeInitParams({
19
+ client,
20
+ creator,
21
+ params,
22
+ });
23
+
24
+ const salt: Hex = generateSalt(options.salt || bytesToHex(randomBytes(31)));
25
+
26
+ const entrypoint = await getDeployedEntrypointERC20(options);
27
+
28
+ let hookData: Hex = "0x";
29
+ let contractId = padHex(toHex("ERC20Asset"), { size: 32 });
30
+ if (launchConfig?.kind === "pool") {
31
+ hookData = encodePoolConfig(launchConfig.config);
32
+ contractId = padHex(toHex("ERC20Asset_Pool"), { size: 32 });
33
+ }
34
+
35
+ const address = await _predictAddress({
36
+ contract: entrypoint,
37
+ contractId,
38
+ params: {
39
+ data: encodedInitData,
40
+ hookData,
41
+ developer: options.developerAddress || DEFAULT_DEVELOPER_ADDRESS,
42
+ salt,
43
+ },
44
+ creator,
45
+ });
46
+
47
+ return address;
48
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.105.34";
1
+ export const version = "5.105.35";