@gala-chain/gala-core-sdk 1.1.0-beta.0 → 1.1.0-beta.2
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.
- package/README.md +32 -6
- package/dist/bridge.cjs +32 -7
- package/dist/bridge.cjs.map +1 -1
- package/dist/bridge.d.cts +26 -0
- package/dist/bridge.d.ts +26 -0
- package/dist/bridge.mjs +32 -8
- package/dist/bridge.mjs.map +1 -1
- package/dist/browser/bridge.js +1 -1
- package/dist/browser/bridge.js.map +1 -1
- package/dist/browser/classes/signers.js +1 -1
- package/dist/browser/classes/signers.js.map +1 -1
- package/dist/browser/config/environments.js +1 -1
- package/dist/browser/config/environments.js.map +1 -1
- package/dist/browser/providers.js.map +1 -1
- package/dist/browser/utils/eip712.js +1 -1
- package/dist/browser/utils/eip712.js.map +1 -1
- package/dist/browser/utils/transport.js +1 -1
- package/dist/browser/version.js +1 -1
- package/dist/browser/version.js.map +1 -1
- package/dist/index.cjs +25 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.mjs +25 -8
- package/dist/index.mjs.map +1 -1
- package/dist/providers.cjs +2 -0
- package/dist/providers.cjs.map +1 -1
- package/dist/providers.d.cts +3 -0
- package/dist/providers.d.ts +3 -0
- package/dist/providers.mjs +2 -0
- package/dist/providers.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{GalaSDKError as e}from"../classes/gala_sdk_error.js";function t(t,n){let r={};r[t]=[];function i(e){let t=r[e];
|
|
2
2
|
/* c8 ignore next */
|
|
3
|
-
if(!t)throw Error(`Missing EIP-712 type definition for ${e}`);return t}function a(t,n,o,s=!1){if(Array.isArray(n)){let e=n.length>0?a(t,n[0],o,!0):`string`;s||i(o).push({name:t,type:(e??t)+`[]`})}else if(typeof n==`object`&&n){if(r[t])throw new e(`EIP712_NAME_COLLISION`,{name:t});r[t]=[],Object.entries(n).forEach(([e,n])=>{a(e,n,t)}),s||i(o).push({name:t,type:t})}else{let r;switch(typeof n){case`string`:r=`string`;break;case`number`:r=`int256`;break;case`boolean`:r=`bool`;break;case`bigint`:case`symbol`:case`undefined`:case`function`:case`object`:throw new e(`EIP712_UNSUPPORTED_VALUE`,{valueType:typeof n})}if(s)return r;i(o).push({name:t,type:r})}}return Object.entries(n).forEach(([e,n])=>{a(e,n,t)}),r}function n(t){let
|
|
3
|
+
if(!t)throw Error(`Missing EIP-712 type definition for ${e}`);return t}function a(t,n,o,s=!1){if(Array.isArray(n)){let e=n.length>0?a(t,n[0],o,!0):`string`;s||i(o).push({name:t,type:(e??t)+`[]`})}else if(typeof n==`object`&&n){if(r[t])throw new e(`EIP712_NAME_COLLISION`,{name:t});r[t]=[],Object.entries(n).forEach(([e,n])=>{a(e,n,t)}),s||i(o).push({name:t,type:t})}else{let r;switch(typeof n){case`string`:r=`string`;break;case`number`:r=`int256`;break;case`boolean`:r=`bool`;break;case`bigint`:case`symbol`:case`undefined`:case`function`:case`object`:throw new e(`EIP712_UNSUPPORTED_VALUE`,{valueType:typeof n})}if(s)return r;i(o).push({name:t,type:r})}}return Object.entries(n).forEach(([e,n])=>{a(e,n,t)}),r}function n(t,n=`ethereum`){let r=typeof t==`string`&&/^0x[0-9a-fA-F]+$/u.test(t)?Number(t):typeof t==`number`?t:NaN;if(!Number.isSafeInteger(r)||r<=0)throw new e(`INVALID_CHAIN_ID`,{chainId:typeof t==`string`||typeof t==`number`?String(t):typeof t});return{name:n,chainId:r}}const r=/* @__PURE__ */ new Set([`RequestTrade`,`AddLiquidity`,`RemoveLiquidity`,`CollectPositionFees`]);function i(e,t){return typeof e[t]==`number`?e[t]:0}function a(e){return{...e,amount0Desired:i(e,`amount0Desired`),amount0Min:i(e,`amount0Min`),amount1Desired:i(e,`amount1Desired`),amount1Min:i(e,`amount1Min`),positionId:e.positionId??``}}function o(e){return{...e,amount:i(e,`amount`),amount0Min:i(e,`amount0Min`),amount1Min:i(e,`amount1Min`),positionId:e.positionId??``}}function s(e){return{...e,amount0Requested:i(e,`amount0Requested`),amount1Requested:i(e,`amount1Requested`),positionId:e.positionId??``}}const c={AddLiquidity:a,RemoveLiquidity:o,CollectPositionFees:s};function l(e,n){let r=c[e],i=r?r(n):n;return{completedDto:i,types:t(e,i)}}export{r as EIP712_CAPABLE_METHODS,c as EIP712_FIELD_COMPLETERS,l as buildEIP712Payload,n as eip712DomainFor,t as generateEIP712Types};
|
|
4
4
|
//# sourceMappingURL=eip712.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip712.js","names":["generateEIP712Types","types","typeName","fieldsFor","fields","name","addField","fieldValue","type","parentTypeName","onlyGetType","GalaSDKError","key","value","eipType","params","eip712DomainFor","parsed","chainId","EIP712_CAPABLE_METHODS","numericOr0","dto","field","completeAddLiquidityFields","\"positionId\"","completeRemoveLiquidityFields","completeCollectPositionFeesFields","EIP712_FIELD_COMPLETERS","buildEIP712Payload","completer","methodName","completedDto"],"sources":["../../../src/utils/eip712.ts"],"sourcesContent":["/**\n * Genuine EIP-712 typed-data signing for the four v2 dex-contract operations, proven by a live\n * bisection against the staging chain to recover the `client|` identity correctly via\n * `eth_signTypedData_v4`, unlike `personal_sign` (which only ever resolves the bare `eth|` form;\n * see `BrowserWalletSigner`'s own doc comment). The field completers mirror the web app's\n * typed-data builders exactly. (Moved from gswap-sdk with the rest of the signing closure; the\n * four methods are dex-contract methods, the derivation is generic.)\n */\nimport { GalaSDKError } from '../classes/gala_sdk_error.js';\n\n/** EIP-712 `types`: each struct name mapped to its ordered `{ name, type }` fields. */\nexport type EIP712Types = Record<string, Array<{ name: string; type: string }>>;\n\n/**\n * Derives the EIP-712 `types` for a DTO from its runtime shape.\n *\n * The generated `types` travel with the signed payload and are what BOTH sides hash, so they\n * must enumerate EVERY field the chain-side DTO will carry. GalaChain refuses any signature\n * whose `types` leave a DTO field uncovered (`assertNoUnsignedFields`, the fix for the\n * 2026-08-18 unsigned-field-injection drain); when that happens signature recovery fails\n * outright and the chain reports \"Missing signerPublicKey or signerAddress field in dto\".\n */\nexport function generateEIP712Types(\n typeName: string,\n params: Record<string, unknown>,\n): EIP712Types {\n const types: EIP712Types = {};\n types[typeName] = [];\n\n // Every `name` this is ever called with (the top-level `typeName`, or a nested struct's own\n // name) is unconditionally assigned `types[name] = []` on the line immediately before any\n // recursive call that could reach here; TypeScript still types `types[name]` as\n // possibly-undefined (index-signature access), so the guard below stays for real type safety\n // even though no current call path can actually trigger it.\n function fieldsFor(name: string): Array<{ name: string; type: string }> {\n const fields = types[name];\n /* c8 ignore next */\n if (!fields) throw new Error(`Missing EIP-712 type definition for ${name}`);\n return fields;\n }\n\n function addField(\n name: string,\n fieldValue: unknown,\n parentTypeName: string,\n onlyGetType = false,\n ): string | undefined {\n if (Array.isArray(fieldValue)) {\n const type =\n fieldValue.length > 0 ? addField(name, fieldValue[0], parentTypeName, true) : 'string';\n if (!onlyGetType) fieldsFor(parentTypeName).push({ name, type: (type ?? name) + '[]' });\n } else if (typeof fieldValue === 'object' && fieldValue !== null) {\n if (types[name]) {\n throw new GalaSDKError('EIP712_NAME_COLLISION', { name });\n }\n types[name] = [];\n Object.entries(fieldValue).forEach(([key, value]) => {\n addField(key, value, name);\n });\n if (!onlyGetType) fieldsFor(parentTypeName).push({ name, type: name });\n } else {\n let eipType: string;\n switch (typeof fieldValue) {\n case 'string':\n eipType = 'string';\n break;\n case 'number':\n eipType = 'int256';\n break;\n case 'boolean':\n eipType = 'bool';\n break;\n case 'bigint':\n case 'symbol':\n case 'undefined':\n case 'function':\n case 'object':\n throw new GalaSDKError('EIP712_UNSUPPORTED_VALUE', { valueType: typeof fieldValue });\n }\n if (onlyGetType) {\n return eipType;\n }\n fieldsFor(parentTypeName).push({ name, type: eipType });\n }\n return undefined;\n }\n\n Object.entries(params).forEach(([key, value]) => {\n addField(key, value, typeName);\n });\n\n return types;\n}\n\n/** The EIP-712 domain carried by a signed payload: GalaChain only uses `name` and `chainId`. */\nexport interface EIP712DomainValue {\n name: string;\n chainId: number;\n}\n\n/**\n * Builds the EIP-712 domain from the wallet's LIVE `eth_chainId` result: a wallet hashes whatever\n * domain it is handed, and MetaMask refuses a `chainId` that differs from its active network, so\n * a hardcoded `1` breaks every wallet that is not on Mainnet.\n * The backend recovers the signer from the `domain` the payload carries (live-proven for chain\n * ids 1, 56 and 11155111), so following the wallet is correct on every network.\n *\n * @param chainId - The raw `eth_chainId` result: a `0x` hex string (the JSON-RPC form) or an integer.\n * @throws GalaSDKError (`INVALID_CHAIN_ID`) when the wallet answers with anything else.\n */\nexport function eip712DomainFor(chainId: unknown): EIP712DomainValue {\n const parsed =\n typeof chainId === 'string' && /^0x[0-9a-fA-F]+$/u.test(chainId)\n ? Number(chainId)\n : typeof chainId === 'number'\n ? chainId\n : Number.NaN;\n if (!Number.isSafeInteger(parsed) || parsed <= 0) {\n throw new GalaSDKError('INVALID_CHAIN_ID', {\n chainId:\n typeof chainId === 'string' || typeof chainId === 'number'\n ? String(chainId)\n : typeof chainId,\n });\n }\n return { name: 'ethereum', chainId: parsed };\n}\n\n/**\n * The four v2 operations proven to recover the signer correctly via genuine EIP-712: `RequestTrade`\n * never had the problem (one numeric field). `AddLiquidity`/`RemoveLiquidity`/\n * `CollectPositionFees` each need their `types` completed with a handful of fields their real\n * server-side DTO always carries — see the `complete*Fields` functions below. `CreatePool` is a\n * genuinely different, unsolved problem (nested `TokenClassKey` structs, not a flat\n * missing-field gap) and is NOT in this set — callers must keep using `personal-sign` for it.\n */\nexport const EIP712_CAPABLE_METHODS: ReadonlySet<string> = new Set([\n 'RequestTrade',\n 'AddLiquidity',\n 'RemoveLiquidity',\n 'CollectPositionFees',\n]);\n\n/**\n * Every `complete*Fields` function below shares the same two live-proven rules:\n * 1. Numeric completeness fields MUST be JS `number`, never numeric strings —\n * `generateEIP712Types` infers a field's Solidity type from `typeof`, and declaring one as\n * EIP-712 `string` instead of `int256` breaks recovery identically to omitting the field\n * entirely (verified live on AddLiquidity: `amount0Min: '0'` fails with the exact same\n * \"Missing signerPublicKey\" error as `amount0Min` being absent; `amount0Min: 0` succeeds).\n * 2. `positionId` has no such constraint — an empty string works, and does not target an\n * existing position (`positionId: ''` created a fresh position on AddLiquidity, not an add\n * to position id `''`; on RemoveLiquidity/CollectPositionFees the real position is still\n * resolved from `token0`/`token1`/`fee`/`tickLower`/`tickUpper`, not from this field).\n */\nfunction numericOr0(dto: Record<string, unknown>, field: string): number {\n return typeof dto[field] === 'number' ? dto[field] : 0;\n}\n\n/**\n * `AddLiquidity`'s real server-side DTO always carries `amount0Desired`/`amount0Min`/\n * `amount1Desired`/`amount1Min`/`positionId` once reconstructed, regardless of which deposit\n * convention the caller used (`Positions.addLiquidityByTicks` only ever sends\n * `depositQuantityToken0`/`depositQuantityToken1`). Proven empirically by bisection: none of the\n * five alone fixes recovery, all five together does (live 201, tx `407d9b24...`, block\n * `2429022`).\n */\nfunction completeAddLiquidityFields(dto: Record<string, unknown>): Record<string, unknown> {\n return {\n ...dto,\n amount0Desired: numericOr0(dto, 'amount0Desired'),\n amount0Min: numericOr0(dto, 'amount0Min'),\n amount1Desired: numericOr0(dto, 'amount1Desired'),\n amount1Min: numericOr0(dto, 'amount1Min'),\n positionId: dto['positionId'] ?? '',\n };\n}\n\n/**\n * `RemoveLiquidity`'s real server-side DTO always carries `amount`/`amount0Min`/`amount1Min`/\n * `positionId` — `Positions.removeLiquidity` only ever sends a `withdrawalQuantityTokenX` (or\n * neither, for a full close). Proven empirically: every subset of these four fails, all four\n * together succeeds (live, random-signer probe — recovery confirmed by the response moving from\n * \"Missing signerPublicKey\" to a genuine position-not-found 404).\n */\nfunction completeRemoveLiquidityFields(dto: Record<string, unknown>): Record<string, unknown> {\n return {\n ...dto,\n amount: numericOr0(dto, 'amount'),\n amount0Min: numericOr0(dto, 'amount0Min'),\n amount1Min: numericOr0(dto, 'amount1Min'),\n positionId: dto['positionId'] ?? '',\n };\n}\n\n/**\n * `CollectPositionFees`'s real server-side DTO always carries `amount0Requested`/\n * `amount1Requested`/`positionId` — `Positions.collectPositionFees` sends only the five identity\n * fields. Proven empirically the same way as `completeRemoveLiquidityFields`.\n */\nfunction completeCollectPositionFeesFields(dto: Record<string, unknown>): Record<string, unknown> {\n return {\n ...dto,\n amount0Requested: numericOr0(dto, 'amount0Requested'),\n amount1Requested: numericOr0(dto, 'amount1Requested'),\n positionId: dto['positionId'] ?? '',\n };\n}\n\nexport const EIP712_FIELD_COMPLETERS: Readonly<\n Record<string, (dto: Record<string, unknown>) => Record<string, unknown>>\n> = {\n AddLiquidity: completeAddLiquidityFields,\n RemoveLiquidity: completeRemoveLiquidityFields,\n CollectPositionFees: completeCollectPositionFeesFields,\n};\n\n/**\n * Completes a DTO's fields for EIP-712 signing (a no-op for methods with no known gap, e.g.\n * `RequestTrade`) and derives its `types`. Exported separately from the signing call itself so tests\n * can assert on the exact payload without needing a live provider.\n */\nexport function buildEIP712Payload(\n methodName: string,\n dto: Record<string, unknown>,\n): { completedDto: Record<string, unknown>; types: EIP712Types } {\n const completer = EIP712_FIELD_COMPLETERS[methodName];\n const completedDto = completer ? completer(dto) : dto;\n const types = generateEIP712Types(methodName, completedDto);\n return { completedDto, types };\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"eip712.js","names":["generateEIP712Types","types","typeName","fieldsFor","fields","name","addField","fieldValue","type","parentTypeName","onlyGetType","GalaSDKError","key","value","eipType","params","eip712DomainFor","parsed","chainId","EIP712_CAPABLE_METHODS","numericOr0","dto","field","completeAddLiquidityFields","\"positionId\"","completeRemoveLiquidityFields","completeCollectPositionFeesFields","EIP712_FIELD_COMPLETERS","buildEIP712Payload","completer","methodName","completedDto"],"sources":["../../../src/utils/eip712.ts"],"sourcesContent":["/**\n * Genuine EIP-712 typed-data signing for the four v2 dex-contract operations, proven by a live\n * bisection against the staging chain to recover the `client|` identity correctly via\n * `eth_signTypedData_v4`, unlike `personal_sign` (which only ever resolves the bare `eth|` form;\n * see `BrowserWalletSigner`'s own doc comment). The field completers mirror the web app's\n * typed-data builders exactly. (Moved from gswap-sdk with the rest of the signing closure; the\n * four methods are dex-contract methods, the derivation is generic.)\n */\nimport { GalaSDKError } from '../classes/gala_sdk_error.js';\n\n/** EIP-712 `types`: each struct name mapped to its ordered `{ name, type }` fields. */\nexport type EIP712Types = Record<string, Array<{ name: string; type: string }>>;\n\n/**\n * Derives the EIP-712 `types` for a DTO from its runtime shape.\n *\n * The generated `types` travel with the signed payload and are what BOTH sides hash, so they\n * must enumerate EVERY field the chain-side DTO will carry. GalaChain refuses any signature\n * whose `types` leave a DTO field uncovered (`assertNoUnsignedFields`, the fix for the\n * 2026-08-18 unsigned-field-injection drain); when that happens signature recovery fails\n * outright and the chain reports \"Missing signerPublicKey or signerAddress field in dto\".\n */\nexport function generateEIP712Types(\n typeName: string,\n params: Record<string, unknown>,\n): EIP712Types {\n const types: EIP712Types = {};\n types[typeName] = [];\n\n // Every `name` this is ever called with (the top-level `typeName`, or a nested struct's own\n // name) is unconditionally assigned `types[name] = []` on the line immediately before any\n // recursive call that could reach here; TypeScript still types `types[name]` as\n // possibly-undefined (index-signature access), so the guard below stays for real type safety\n // even though no current call path can actually trigger it.\n function fieldsFor(name: string): Array<{ name: string; type: string }> {\n const fields = types[name];\n /* c8 ignore next */\n if (!fields) throw new Error(`Missing EIP-712 type definition for ${name}`);\n return fields;\n }\n\n function addField(\n name: string,\n fieldValue: unknown,\n parentTypeName: string,\n onlyGetType = false,\n ): string | undefined {\n if (Array.isArray(fieldValue)) {\n const type =\n fieldValue.length > 0 ? addField(name, fieldValue[0], parentTypeName, true) : 'string';\n if (!onlyGetType) fieldsFor(parentTypeName).push({ name, type: (type ?? name) + '[]' });\n } else if (typeof fieldValue === 'object' && fieldValue !== null) {\n if (types[name]) {\n throw new GalaSDKError('EIP712_NAME_COLLISION', { name });\n }\n types[name] = [];\n Object.entries(fieldValue).forEach(([key, value]) => {\n addField(key, value, name);\n });\n if (!onlyGetType) fieldsFor(parentTypeName).push({ name, type: name });\n } else {\n let eipType: string;\n switch (typeof fieldValue) {\n case 'string':\n eipType = 'string';\n break;\n case 'number':\n eipType = 'int256';\n break;\n case 'boolean':\n eipType = 'bool';\n break;\n case 'bigint':\n case 'symbol':\n case 'undefined':\n case 'function':\n case 'object':\n throw new GalaSDKError('EIP712_UNSUPPORTED_VALUE', { valueType: typeof fieldValue });\n }\n if (onlyGetType) {\n return eipType;\n }\n fieldsFor(parentTypeName).push({ name, type: eipType });\n }\n return undefined;\n }\n\n Object.entries(params).forEach(([key, value]) => {\n addField(key, value, typeName);\n });\n\n return types;\n}\n\n/** The EIP-712 domain carried by a signed payload: GalaChain only uses `name` and `chainId`. */\nexport interface EIP712DomainValue {\n name: string;\n chainId: number;\n}\n\n/**\n * Builds the EIP-712 domain from the wallet's LIVE `eth_chainId` result: a wallet hashes whatever\n * domain it is handed, and MetaMask refuses a `chainId` that differs from its active network, so\n * a hardcoded `1` breaks every wallet that is not on Mainnet.\n * The backend recovers the signer from the `domain` the payload carries (live-proven for chain\n * ids 1, 56 and 11155111), so following the wallet is correct on every network.\n *\n * @param chainId - The raw `eth_chainId` result: a `0x` hex string (the JSON-RPC form) or an integer.\n * @param name - The domain name the deployment requires (`GALA_CHAIN_ENVIRONMENTS[env].eip712DomainName`);\n * `'ethereum'`, what every signer has always signed, when absent.\n * @throws GalaSDKError (`INVALID_CHAIN_ID`) when the wallet answers with anything else.\n */\nexport function eip712DomainFor(chainId: unknown, name = 'ethereum'): EIP712DomainValue {\n const parsed =\n typeof chainId === 'string' && /^0x[0-9a-fA-F]+$/u.test(chainId)\n ? Number(chainId)\n : typeof chainId === 'number'\n ? chainId\n : Number.NaN;\n if (!Number.isSafeInteger(parsed) || parsed <= 0) {\n throw new GalaSDKError('INVALID_CHAIN_ID', {\n chainId:\n typeof chainId === 'string' || typeof chainId === 'number'\n ? String(chainId)\n : typeof chainId,\n });\n }\n return { name, chainId: parsed };\n}\n\n/**\n * The four v2 operations proven to recover the signer correctly via genuine EIP-712: `RequestTrade`\n * never had the problem (one numeric field). `AddLiquidity`/`RemoveLiquidity`/\n * `CollectPositionFees` each need their `types` completed with a handful of fields their real\n * server-side DTO always carries — see the `complete*Fields` functions below. `CreatePool` is a\n * genuinely different, unsolved problem (nested `TokenClassKey` structs, not a flat\n * missing-field gap) and is NOT in this set — callers must keep using `personal-sign` for it.\n */\nexport const EIP712_CAPABLE_METHODS: ReadonlySet<string> = new Set([\n 'RequestTrade',\n 'AddLiquidity',\n 'RemoveLiquidity',\n 'CollectPositionFees',\n]);\n\n/**\n * Every `complete*Fields` function below shares the same two live-proven rules:\n * 1. Numeric completeness fields MUST be JS `number`, never numeric strings —\n * `generateEIP712Types` infers a field's Solidity type from `typeof`, and declaring one as\n * EIP-712 `string` instead of `int256` breaks recovery identically to omitting the field\n * entirely (verified live on AddLiquidity: `amount0Min: '0'` fails with the exact same\n * \"Missing signerPublicKey\" error as `amount0Min` being absent; `amount0Min: 0` succeeds).\n * 2. `positionId` has no such constraint — an empty string works, and does not target an\n * existing position (`positionId: ''` created a fresh position on AddLiquidity, not an add\n * to position id `''`; on RemoveLiquidity/CollectPositionFees the real position is still\n * resolved from `token0`/`token1`/`fee`/`tickLower`/`tickUpper`, not from this field).\n */\nfunction numericOr0(dto: Record<string, unknown>, field: string): number {\n return typeof dto[field] === 'number' ? dto[field] : 0;\n}\n\n/**\n * `AddLiquidity`'s real server-side DTO always carries `amount0Desired`/`amount0Min`/\n * `amount1Desired`/`amount1Min`/`positionId` once reconstructed, regardless of which deposit\n * convention the caller used (`Positions.addLiquidityByTicks` only ever sends\n * `depositQuantityToken0`/`depositQuantityToken1`). Proven empirically by bisection: none of the\n * five alone fixes recovery, all five together does (live 201, tx `407d9b24...`, block\n * `2429022`).\n */\nfunction completeAddLiquidityFields(dto: Record<string, unknown>): Record<string, unknown> {\n return {\n ...dto,\n amount0Desired: numericOr0(dto, 'amount0Desired'),\n amount0Min: numericOr0(dto, 'amount0Min'),\n amount1Desired: numericOr0(dto, 'amount1Desired'),\n amount1Min: numericOr0(dto, 'amount1Min'),\n positionId: dto['positionId'] ?? '',\n };\n}\n\n/**\n * `RemoveLiquidity`'s real server-side DTO always carries `amount`/`amount0Min`/`amount1Min`/\n * `positionId` — `Positions.removeLiquidity` only ever sends a `withdrawalQuantityTokenX` (or\n * neither, for a full close). Proven empirically: every subset of these four fails, all four\n * together succeeds (live, random-signer probe — recovery confirmed by the response moving from\n * \"Missing signerPublicKey\" to a genuine position-not-found 404).\n */\nfunction completeRemoveLiquidityFields(dto: Record<string, unknown>): Record<string, unknown> {\n return {\n ...dto,\n amount: numericOr0(dto, 'amount'),\n amount0Min: numericOr0(dto, 'amount0Min'),\n amount1Min: numericOr0(dto, 'amount1Min'),\n positionId: dto['positionId'] ?? '',\n };\n}\n\n/**\n * `CollectPositionFees`'s real server-side DTO always carries `amount0Requested`/\n * `amount1Requested`/`positionId` — `Positions.collectPositionFees` sends only the five identity\n * fields. Proven empirically the same way as `completeRemoveLiquidityFields`.\n */\nfunction completeCollectPositionFeesFields(dto: Record<string, unknown>): Record<string, unknown> {\n return {\n ...dto,\n amount0Requested: numericOr0(dto, 'amount0Requested'),\n amount1Requested: numericOr0(dto, 'amount1Requested'),\n positionId: dto['positionId'] ?? '',\n };\n}\n\nexport const EIP712_FIELD_COMPLETERS: Readonly<\n Record<string, (dto: Record<string, unknown>) => Record<string, unknown>>\n> = {\n AddLiquidity: completeAddLiquidityFields,\n RemoveLiquidity: completeRemoveLiquidityFields,\n CollectPositionFees: completeCollectPositionFeesFields,\n};\n\n/**\n * Completes a DTO's fields for EIP-712 signing (a no-op for methods with no known gap, e.g.\n * `RequestTrade`) and derives its `types`. Exported separately from the signing call itself so tests\n * can assert on the exact payload without needing a live provider.\n */\nexport function buildEIP712Payload(\n methodName: string,\n dto: Record<string, unknown>,\n): { completedDto: Record<string, unknown>; types: EIP712Types } {\n const completer = EIP712_FIELD_COMPLETERS[methodName];\n const completedDto = completer ? completer(dto) : dto;\n const types = generateEIP712Types(methodName, completedDto);\n return { completedDto, types };\n}\n"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{GalaSDKError as e,isGalaError as t,parseJson as n}from"../classes/gala_sdk_error.js";import"../version.js";function r(e,t){if(t===1/0)return()=>void 0;let n=setTimeout(()=>e.abort(),t);return()=>clearTimeout(n)}function i(t,n){if(t===1/0||Number.isFinite(t)&&t>0)return t;throw new e(`INVALID_TIMEOUT`,{field:n,value:t})}const a=/[A-Za-z0-9\-._~!'()*$|:,]/u;function o(e){let t=``;for(let n of e)n===` `?t+=`+`:a.test(n)?t+=n:t+=s(n);return t}function s(e){try{return encodeURIComponent(e)}catch{return`%EF%BF%BD`}}function c(e,t=`standard`){return t===`readable`?Object.entries(e).map(([e,t])=>`${o(e)}=${o(t)}`).join(`&`):new URLSearchParams(e).toString()}function l(e,t={}){let n=/* @__PURE__ */ new Map,r=(e,t=!1)=>{for(let[r,i]of Object.entries(e??{}))t&&n.delete(r.toLowerCase()),n.set(r.toLowerCase(),[r,i])};return e?.userAgent!==!1&&r({"User-Agent":e?.userAgent??`GalaChain-SDK/1.1.0-beta.
|
|
1
|
+
import{GalaSDKError as e,isGalaError as t,parseJson as n}from"../classes/gala_sdk_error.js";import"../version.js";function r(e,t){if(t===1/0)return()=>void 0;let n=setTimeout(()=>e.abort(),t);return()=>clearTimeout(n)}function i(t,n){if(t===1/0||Number.isFinite(t)&&t>0)return t;throw new e(`INVALID_TIMEOUT`,{field:n,value:t})}const a=/[A-Za-z0-9\-._~!'()*$|:,]/u;function o(e){let t=``;for(let n of e)n===` `?t+=`+`:a.test(n)?t+=n:t+=s(n);return t}function s(e){try{return encodeURIComponent(e)}catch{return`%EF%BF%BD`}}function c(e,t=`standard`){return t===`readable`?Object.entries(e).map(([e,t])=>`${o(e)}=${o(t)}`).join(`&`):new URLSearchParams(e).toString()}function l(e,t={}){let n=/* @__PURE__ */ new Map,r=(e,t=!1)=>{for(let[r,i]of Object.entries(e??{}))t&&n.delete(r.toLowerCase()),n.set(r.toLowerCase(),[r,i])};return e?.userAgent!==!1&&r({"User-Agent":e?.userAgent??`GalaChain-SDK/1.1.0-beta.2`}),r(t.defaults),r(e?.headers),t.json===!0&&!n.has(`content-type`)&&r({"Content-Type":`application/json`}),r(t.fixed,!0),Object.fromEntries(n.values())}const u=async(t,n)=>{try{return await fetch(t,n)}catch(r){throw n?.signal?.aborted===!0?r:new e(`TRANSPORT_ERROR`,{url:t},{url:t,cause:r})}};async function d(n,i,a,o,s){let c=new AbortController,l=r(c,o),u=a.signal,d=()=>c.abort();u?.addEventListener(`abort`,d,{once:!0});let f=s?.write===!1;try{return await n(i,{...a,signal:c.signal})}catch(n){throw u?.aborted===!0?n:c.signal.aborted?new e(`REQUEST_TIMEOUT`,{url:i,timeoutMs:o},{url:i,cause:n,...f?{write:!1}:{}}):f&&t(n,`TRANSPORT_ERROR`)&&n.write?new e(`TRANSPORT_ERROR`,{url:n.url??i},{url:n.url??i,cause:n.cause,write:!1}):n}finally{l(),u?.removeEventListener(`abort`,d)}}async function f(e){let t=await e.text();return n(t)??t}function p(e,t){let n=e.headers;if(n===void 0)return;if(g(n)){let e=n.get(t);return e===null||e===``?void 0:e}let r=Object.entries(n).find(([e])=>e.toLowerCase()===t.toLowerCase())?.[1];return r===void 0||r===``?void 0:r}function m(e){let t=p(e,`retry-after`);if(t===void 0)return;let n=Number(t);if(Number.isFinite(n)&&n>=0)return n*1e3;let r=Date.parse(t);return Number.isNaN(r)?void 0:Math.max(0,r-Date.now())}function h(e,t=`x-block-number`){let n=p(e,t);if(n===void 0)return;let r=Number(n);return Number.isInteger(r)&&r>=0?r:void 0}function g(e){return`get`in e&&typeof e.get==`function`}export{r as armTimeout,c as buildQueryString,l as buildRequestHeaders,u as fetchRequestor,h as readBlockNumberHeader,p as readHeader,f as readResponseBody,m as readRetryAfter,d as requestWithTimeout,i as validateTimeoutMs};
|
|
2
2
|
//# sourceMappingURL=transport.js.map
|
package/dist/browser/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=`1.1.0-beta.
|
|
1
|
+
const e=`1.1.0-beta.2`;export{e as GALA_CORE_SDK_VERSION};
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":["GALA_CORE_SDK_VERSION"],"sources":["../../src/version.ts"],"sourcesContent":["declare const __GALA_CORE_SDK_VERSION__: string | undefined;\n\n/**\n * The `@gala-chain/gala-core-sdk` package version, embedded by the bundler, with a source-test\n * fallback. It is the version in the default `User-Agent` (`GalaChain-SDK/<version>`) of every SDK\n * request, whichever product SDK sends it.\n */\nexport const GALA_CORE_SDK_VERSION =\n typeof __GALA_CORE_SDK_VERSION__ === 'string' ? __GALA_CORE_SDK_VERSION__ : '1.1.0-beta.
|
|
1
|
+
{"version":3,"file":"version.js","names":["GALA_CORE_SDK_VERSION"],"sources":["../../src/version.ts"],"sourcesContent":["declare const __GALA_CORE_SDK_VERSION__: string | undefined;\n\n/**\n * The `@gala-chain/gala-core-sdk` package version, embedded by the bundler, with a source-test\n * fallback. It is the version in the default `User-Agent` (`GalaChain-SDK/<version>`) of every SDK\n * request, whichever product SDK sends it.\n */\nexport const GALA_CORE_SDK_VERSION =\n typeof __GALA_CORE_SDK_VERSION__ === 'string' ? __GALA_CORE_SDK_VERSION__ : '1.1.0-beta.2';\n"],"mappings":"AAOA,MAAaA,EAAA,e"}
|
package/dist/index.cjs
CHANGED
|
@@ -1362,13 +1362,15 @@ function generateEIP712Types(typeName, params) {
|
|
|
1362
1362
|
* ids 1, 56 and 11155111), so following the wallet is correct on every network.
|
|
1363
1363
|
*
|
|
1364
1364
|
* @param chainId - The raw `eth_chainId` result: a `0x` hex string (the JSON-RPC form) or an integer.
|
|
1365
|
+
* @param name - The domain name the deployment requires (`GALA_CHAIN_ENVIRONMENTS[env].eip712DomainName`);
|
|
1366
|
+
* `'ethereum'`, what every signer has always signed, when absent.
|
|
1365
1367
|
* @throws GalaSDKError (`INVALID_CHAIN_ID`) when the wallet answers with anything else.
|
|
1366
1368
|
*/
|
|
1367
|
-
function eip712DomainFor(chainId) {
|
|
1369
|
+
function eip712DomainFor(chainId, name = "ethereum") {
|
|
1368
1370
|
const parsed = typeof chainId === "string" && /^0x[0-9a-fA-F]+$/u.test(chainId) ? Number(chainId) : typeof chainId === "number" ? chainId : NaN;
|
|
1369
1371
|
if (!Number.isSafeInteger(parsed) || parsed <= 0) throw new GalaSDKError("INVALID_CHAIN_ID", { chainId: typeof chainId === "string" || typeof chainId === "number" ? String(chainId) : typeof chainId });
|
|
1370
1372
|
return {
|
|
1371
|
-
name
|
|
1373
|
+
name,
|
|
1372
1374
|
chainId: parsed
|
|
1373
1375
|
};
|
|
1374
1376
|
}
|
|
@@ -1806,12 +1808,12 @@ function personalSign(provider, dto, walletAddress, methodName) {
|
|
|
1806
1808
|
* byte-for-byte equivalent (same recovered address from the same signature against both
|
|
1807
1809
|
* constructions) before this shipped, since the core SDK deliberately has no ethers dependency.
|
|
1808
1810
|
*/
|
|
1809
|
-
async function signEIP712(provider, methodName, dto, walletAddress) {
|
|
1811
|
+
async function signEIP712(provider, methodName, dto, walletAddress, domainName) {
|
|
1810
1812
|
const { completedDto, types } = buildEIP712Payload(methodName, dto);
|
|
1811
1813
|
const domain = eip712DomainFor(await provider.request({
|
|
1812
1814
|
method: "eth_chainId",
|
|
1813
1815
|
params: []
|
|
1814
|
-
}));
|
|
1816
|
+
}), domainName);
|
|
1815
1817
|
const prefix = fixpointPrefixFor(completedDto);
|
|
1816
1818
|
const message = {
|
|
1817
1819
|
...completedDto,
|
|
@@ -2043,6 +2045,10 @@ var BrowserWalletSigner = class {
|
|
|
2043
2045
|
* falls back to `personal_sign` even in `'eip712'` mode, since its EIP-712 signing is a
|
|
2044
2046
|
* separate, unsolved chain-side problem.
|
|
2045
2047
|
*
|
|
2048
|
+
* `eip712DomainName` is the EIP-712 domain name every typed-data signature carries (the
|
|
2049
|
+
* `'eip712'` scheme only; `personal_sign` has no domain): the deployment's own
|
|
2050
|
+
* (`GALA_CHAIN_ENVIRONMENTS[env].eip712DomainName`), `ethereum` when absent.
|
|
2051
|
+
*
|
|
2046
2052
|
* @example
|
|
2047
2053
|
* ```typescript
|
|
2048
2054
|
* const signer = new BrowserWalletSigner(window.ethereum, '0x0123456789012345678901234567890123456789');
|
|
@@ -2053,15 +2059,25 @@ var BrowserWalletSigner = class {
|
|
|
2053
2059
|
* // Correctly resolves a registered client| alias instead of the bare eth| address.
|
|
2054
2060
|
* const signer = new BrowserWalletSigner(window.ethereum, walletAddress, { scheme: 'eip712' });
|
|
2055
2061
|
* ```
|
|
2062
|
+
* @example
|
|
2063
|
+
* ```typescript
|
|
2064
|
+
* // The stage chain refuses any EIP-712 domain name but its own.
|
|
2065
|
+
* const signer = new BrowserWalletSigner(window.ethereum, walletAddress, {
|
|
2066
|
+
* scheme: 'eip712',
|
|
2067
|
+
* eip712DomainName: GALA_CHAIN_ENVIRONMENTS.stage.eip712DomainName,
|
|
2068
|
+
* });
|
|
2069
|
+
* ```
|
|
2056
2070
|
*/
|
|
2057
2071
|
constructor(provider, walletAddress, options = {}) {
|
|
2058
2072
|
this.provider = provider;
|
|
2059
2073
|
this.walletAddress = normalizeEthereumAccount(walletAddress, false);
|
|
2060
2074
|
this.scheme = options.scheme ?? "personal-sign";
|
|
2075
|
+
this.eip712DomainName = options.eip712DomainName;
|
|
2061
2076
|
}
|
|
2062
2077
|
/** The selected `0x` Ethereum account every signature is requested for. */
|
|
2063
2078
|
walletAddress;
|
|
2064
2079
|
scheme;
|
|
2080
|
+
eip712DomainName;
|
|
2065
2081
|
/**
|
|
2066
2082
|
* Signs the DTO with `eth_signTypedData_v4` (when constructed with `{ scheme: 'eip712' }` and
|
|
2067
2083
|
* `methodName` is in `EIP712_CAPABLE_METHODS`) or the EIP-1193 `personal_sign` method
|
|
@@ -2077,7 +2093,7 @@ var BrowserWalletSigner = class {
|
|
|
2077
2093
|
* ```
|
|
2078
2094
|
*/
|
|
2079
2095
|
signObject(methodName, dto) {
|
|
2080
|
-
if (this.scheme === "eip712" && EIP712_CAPABLE_METHODS.has(methodName)) return signEIP712(this.provider, methodName, dto, this.walletAddress);
|
|
2096
|
+
if (this.scheme === "eip712" && EIP712_CAPABLE_METHODS.has(methodName)) return signEIP712(this.provider, methodName, dto, this.walletAddress, this.eip712DomainName);
|
|
2081
2097
|
return personalSign(this.provider, dto, this.walletAddress);
|
|
2082
2098
|
}
|
|
2083
2099
|
};
|
|
@@ -2820,7 +2836,7 @@ async function signPreSend(signer, contractPath, method, dto) {
|
|
|
2820
2836
|
* fallback. It is the version in the default `User-Agent` (`GalaChain-SDK/<version>`) of every SDK
|
|
2821
2837
|
* request, whichever product SDK sends it.
|
|
2822
2838
|
*/
|
|
2823
|
-
const GALA_CORE_SDK_VERSION = "1.1.0-beta.
|
|
2839
|
+
const GALA_CORE_SDK_VERSION = "1.1.0-beta.2";
|
|
2824
2840
|
|
|
2825
2841
|
//#endregion
|
|
2826
2842
|
//#region src/utils/transport.ts
|
|
@@ -2881,7 +2897,7 @@ function buildRequestHeaders(wire, parts = {}) {
|
|
|
2881
2897
|
entries.set(name.toLowerCase(), [name, value]);
|
|
2882
2898
|
}
|
|
2883
2899
|
};
|
|
2884
|
-
if ((wire === null || wire === void 0 ? void 0 : wire.userAgent) !== false) put({ "User-Agent": (wire === null || wire === void 0 ? void 0 : wire.userAgent) ?? `GalaChain-SDK/${"1.1.0-beta.
|
|
2900
|
+
if ((wire === null || wire === void 0 ? void 0 : wire.userAgent) !== false) put({ "User-Agent": (wire === null || wire === void 0 ? void 0 : wire.userAgent) ?? `GalaChain-SDK/${"1.1.0-beta.2"}` });
|
|
2885
2901
|
put(parts.defaults);
|
|
2886
2902
|
put(wire === null || wire === void 0 ? void 0 : wire.headers);
|
|
2887
2903
|
if (parts.json === true && !entries.has("content-type")) put({ "Content-Type": "application/json" });
|
|
@@ -4870,7 +4886,8 @@ const GALA_CHAIN_ENVIRONMENTS = Object.freeze({
|
|
|
4870
4886
|
}),
|
|
4871
4887
|
stage: Object.freeze({
|
|
4872
4888
|
gatewayBaseUrl: "https://gateway-testnet.galachain.com",
|
|
4873
|
-
dexApiBaseUrl: "https://dex-api-platform-dex-stage-gala.gala.com"
|
|
4889
|
+
dexApiBaseUrl: "https://dex-api-platform-dex-stage-gala.gala.com",
|
|
4890
|
+
eip712DomainName: "GalaChainStage"
|
|
4874
4891
|
})
|
|
4875
4892
|
});
|
|
4876
4893
|
|