@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/dist/bridge.d.cts CHANGED
@@ -789,6 +789,15 @@ export declare const GALA_BRIDGE_TYPED_DATA_DOMAIN: {
789
789
  readonly name: 'GalaConnect';
790
790
  readonly chainId: 1;
791
791
  };
792
+ /**
793
+ * The bridge-out typed data domain for a deployment: {@link GALA_BRIDGE_TYPED_DATA_DOMAIN}, or the
794
+ * same domain under the name the deployment's chain requires
795
+ * (`GALA_CHAIN_ENVIRONMENTS[env].eip712DomainName`, `GalaChainStage` on stage).
796
+ */
797
+ export declare function galaBridgeTypedDataDomain(name?: string): {
798
+ readonly name: string;
799
+ readonly chainId: 1;
800
+ };
792
801
  /**
793
802
  * EIP-712 type definition
794
803
  */
@@ -1817,6 +1826,11 @@ interface BridgeServiceConfig extends Omit<BridgeConfig, 'galaConnectBaseUrl'> {
1817
1826
  ethereumPrivateKey: string;
1818
1827
  /** Environment - affects default URLs (stage: Sepolia and devnet, prod: mainnet). Default prod. */
1819
1828
  environment?: BridgeEnvironment;
1829
+ /**
1830
+ * The EIP-712 domain name of the bridge-out typed data. Default: the environment's
1831
+ * (`GalaChainStage` on stage), else `GalaConnect`, what has always been signed.
1832
+ */
1833
+ eip712DomainName?: string;
1820
1834
  /**
1821
1835
  * Resolves a `tokenId` to the token bridgeable to a network (the `BridgeableTokenService`).
1822
1836
  * Every method that takes a `tokenId` goes through it, so it is required: a missing lookup is
@@ -2205,6 +2219,8 @@ interface EthereumBridgeConfig {
2205
2219
  tokenConfigs?: EthereumTokenConfig[];
2206
2220
  /** How the strategy waits (the delay before an inbound registration). Default: a timer. */
2207
2221
  sleep?: BridgeSleep;
2222
+ /** The EIP-712 domain name of the bridge-out typed data (default `GalaConnect`). */
2223
+ eip712DomainName?: string | undefined;
2208
2224
  }
2209
2225
  /**
2210
2226
  * Bridge strategy for GalaChain ↔ Ethereum transfers.
@@ -2224,6 +2240,7 @@ export declare class EthereumBridgeStrategy extends ConfiguredBridgeStrategy<Eth
2224
2240
  private readonly ethereumBridgeContract;
2225
2241
  private readonly ethereumWalletAddress;
2226
2242
  private readonly tokenMetadataResolver;
2243
+ private readonly eip712DomainName;
2227
2244
  /**
2228
2245
  * Creates a new Ethereum bridge strategy.
2229
2246
  *
@@ -2339,6 +2356,8 @@ interface SolanaBridgeConfig {
2339
2356
  tokenConfigs?: SolanaTokenConfig[];
2340
2357
  /** How the strategy waits (the backoff before a resend). Default: a timer. */
2341
2358
  sleep?: BridgeSleep;
2359
+ /** The EIP-712 domain name of the bridge-out typed data (default `GalaConnect`). */
2360
+ eip712DomainName?: string | undefined;
2342
2361
  }
2343
2362
  /**
2344
2363
  * Bridge strategy for GalaChain ↔ Solana transfers.
@@ -2349,6 +2368,7 @@ export declare class SolanaBridgeStrategy extends ConfiguredBridgeStrategy<Solan
2349
2368
  readonly network: ExternalNetwork;
2350
2369
  private readonly galaChainWalletAddress;
2351
2370
  private readonly ethereumWallet;
2371
+ private readonly eip712DomainName;
2352
2372
  private readonly solanaConnection;
2353
2373
  private readonly solanaKeypair;
2354
2374
  private readonly solanaBridgeProgramId;
@@ -2530,6 +2550,12 @@ type BridgeTypedDataSigner = Pick<Signer, 'signTypedData'>;
2530
2550
  interface BuildBridgeOutPayloadConfig {
2531
2551
  /** Signs the EIP-712 typed data (the Ethereum wallet) */
2532
2552
  wallet: BridgeTypedDataSigner;
2553
+ /**
2554
+ * The EIP-712 domain name the deployment's chain requires
2555
+ * (`GALA_CHAIN_ENVIRONMENTS[env].eip712DomainName`); `GalaConnect`, what has always been signed,
2556
+ * when absent.
2557
+ */
2558
+ eip712DomainName?: string | undefined;
2533
2559
  }
2534
2560
  /** The signed `RequestTokenBridgeOut` body; its `uniqueKey` is the bridge-out's handle. */
2535
2561
  type SignedBridgeOutPayload = Record<string, unknown> & {
package/dist/bridge.d.ts CHANGED
@@ -789,6 +789,15 @@ export declare const GALA_BRIDGE_TYPED_DATA_DOMAIN: {
789
789
  readonly name: 'GalaConnect';
790
790
  readonly chainId: 1;
791
791
  };
792
+ /**
793
+ * The bridge-out typed data domain for a deployment: {@link GALA_BRIDGE_TYPED_DATA_DOMAIN}, or the
794
+ * same domain under the name the deployment's chain requires
795
+ * (`GALA_CHAIN_ENVIRONMENTS[env].eip712DomainName`, `GalaChainStage` on stage).
796
+ */
797
+ export declare function galaBridgeTypedDataDomain(name?: string): {
798
+ readonly name: string;
799
+ readonly chainId: 1;
800
+ };
792
801
  /**
793
802
  * EIP-712 type definition
794
803
  */
@@ -1817,6 +1826,11 @@ interface BridgeServiceConfig extends Omit<BridgeConfig, 'galaConnectBaseUrl'> {
1817
1826
  ethereumPrivateKey: string;
1818
1827
  /** Environment - affects default URLs (stage: Sepolia and devnet, prod: mainnet). Default prod. */
1819
1828
  environment?: BridgeEnvironment;
1829
+ /**
1830
+ * The EIP-712 domain name of the bridge-out typed data. Default: the environment's
1831
+ * (`GalaChainStage` on stage), else `GalaConnect`, what has always been signed.
1832
+ */
1833
+ eip712DomainName?: string;
1820
1834
  /**
1821
1835
  * Resolves a `tokenId` to the token bridgeable to a network (the `BridgeableTokenService`).
1822
1836
  * Every method that takes a `tokenId` goes through it, so it is required: a missing lookup is
@@ -2205,6 +2219,8 @@ interface EthereumBridgeConfig {
2205
2219
  tokenConfigs?: EthereumTokenConfig[];
2206
2220
  /** How the strategy waits (the delay before an inbound registration). Default: a timer. */
2207
2221
  sleep?: BridgeSleep;
2222
+ /** The EIP-712 domain name of the bridge-out typed data (default `GalaConnect`). */
2223
+ eip712DomainName?: string | undefined;
2208
2224
  }
2209
2225
  /**
2210
2226
  * Bridge strategy for GalaChain ↔ Ethereum transfers.
@@ -2224,6 +2240,7 @@ export declare class EthereumBridgeStrategy extends ConfiguredBridgeStrategy<Eth
2224
2240
  private readonly ethereumBridgeContract;
2225
2241
  private readonly ethereumWalletAddress;
2226
2242
  private readonly tokenMetadataResolver;
2243
+ private readonly eip712DomainName;
2227
2244
  /**
2228
2245
  * Creates a new Ethereum bridge strategy.
2229
2246
  *
@@ -2339,6 +2356,8 @@ interface SolanaBridgeConfig {
2339
2356
  tokenConfigs?: SolanaTokenConfig[];
2340
2357
  /** How the strategy waits (the backoff before a resend). Default: a timer. */
2341
2358
  sleep?: BridgeSleep;
2359
+ /** The EIP-712 domain name of the bridge-out typed data (default `GalaConnect`). */
2360
+ eip712DomainName?: string | undefined;
2342
2361
  }
2343
2362
  /**
2344
2363
  * Bridge strategy for GalaChain ↔ Solana transfers.
@@ -2349,6 +2368,7 @@ export declare class SolanaBridgeStrategy extends ConfiguredBridgeStrategy<Solan
2349
2368
  readonly network: ExternalNetwork;
2350
2369
  private readonly galaChainWalletAddress;
2351
2370
  private readonly ethereumWallet;
2371
+ private readonly eip712DomainName;
2352
2372
  private readonly solanaConnection;
2353
2373
  private readonly solanaKeypair;
2354
2374
  private readonly solanaBridgeProgramId;
@@ -2530,6 +2550,12 @@ type BridgeTypedDataSigner = Pick<Signer, 'signTypedData'>;
2530
2550
  interface BuildBridgeOutPayloadConfig {
2531
2551
  /** Signs the EIP-712 typed data (the Ethereum wallet) */
2532
2552
  wallet: BridgeTypedDataSigner;
2553
+ /**
2554
+ * The EIP-712 domain name the deployment's chain requires
2555
+ * (`GALA_CHAIN_ENVIRONMENTS[env].eip712DomainName`); `GalaConnect`, what has always been signed,
2556
+ * when absent.
2557
+ */
2558
+ eip712DomainName?: string | undefined;
2533
2559
  }
2534
2560
  /** The signed `RequestTokenBridgeOut` body; its `uniqueKey` is the bridge-out's handle. */
2535
2561
  type SignedBridgeOutPayload = Record<string, unknown> & {
package/dist/bridge.mjs CHANGED
@@ -38,6 +38,17 @@ const GALA_BRIDGE_TYPED_DATA_DOMAIN = {
38
38
  chainId: 1
39
39
  };
40
40
  /**
41
+ * The bridge-out typed data domain for a deployment: {@link GALA_BRIDGE_TYPED_DATA_DOMAIN}, or the
42
+ * same domain under the name the deployment's chain requires
43
+ * (`GALA_CHAIN_ENVIRONMENTS[env].eip712DomainName`, `GalaChainStage` on stage).
44
+ */
45
+ function galaBridgeTypedDataDomain(name) {
46
+ return name === void 0 ? GALA_BRIDGE_TYPED_DATA_DOMAIN : {
47
+ name,
48
+ chainId: 1
49
+ };
50
+ }
51
+ /**
41
52
  * Common GalaTransaction fields (identical in both schemas)
42
53
  */
43
54
  const GALA_TRANSACTION_TYPE = [
@@ -2188,10 +2199,10 @@ const BRIDGE_OUT_METHOD = "RequestTokenBridgeOut";
2188
2199
  * `SIGNING_FAILED` (`user_rejected` or `failed`, the original as `cause`), and so is a signature
2189
2200
  * that is not a string: nothing was sent, so a retry is safe.
2190
2201
  */
2191
- async function signBridgeOut(wallet, types, message) {
2202
+ async function signBridgeOut(wallet, domain, types, message) {
2192
2203
  let signature;
2193
2204
  try {
2194
- signature = await wallet.signTypedData(GALA_BRIDGE_TYPED_DATA_DOMAIN, types, message);
2205
+ signature = await wallet.signTypedData(domain, types, message);
2195
2206
  } catch (cause) {
2196
2207
  if (isGalaError(cause)) throw cause;
2197
2208
  throw new GalaSDKError("SIGNING_FAILED", {
@@ -2249,9 +2260,10 @@ async function buildBridgeOutPayload(dto, config) {
2249
2260
  uniqueKey
2250
2261
  };
2251
2262
  const typedDataTypes = getGalaBridgeTypedDataTypes(hasCrossRate);
2252
- const signature = await signBridgeOut(wallet, typedDataTypes, message);
2263
+ const domain = galaBridgeTypedDataDomain(config.eip712DomainName);
2264
+ const signature = await signBridgeOut(wallet, domain, typedDataTypes, message);
2253
2265
  const prefix = `\u0019Ethereum Signed Message:\n${serialize({
2254
- domain: GALA_BRIDGE_TYPED_DATA_DOMAIN,
2266
+ domain,
2255
2267
  message,
2256
2268
  primaryType: "GalaTransaction",
2257
2269
  types: typedDataTypes
@@ -2261,7 +2273,7 @@ async function buildBridgeOutPayload(dto, config) {
2261
2273
  signature,
2262
2274
  prefix,
2263
2275
  types: typedDataTypes,
2264
- domain: GALA_BRIDGE_TYPED_DATA_DOMAIN
2276
+ domain
2265
2277
  };
2266
2278
  }
2267
2279
 
@@ -2326,7 +2338,7 @@ async function completeBridgeOut(galaConnectClient, requestResponse, uniqueKey,
2326
2338
  */
2327
2339
  async function executeBridgeOutFlow(params, config) {
2328
2340
  const { amount, recipientAddress, tokenSymbol: resolvedSymbol } = params;
2329
- const { galaConnectClient, tokenMetadataResolver, ethereumWallet, destinationChainId, destinationChain, validateRecipientAddress } = config;
2341
+ const { galaConnectClient, tokenMetadataResolver, ethereumWallet, eip712DomainName, destinationChainId, destinationChain, validateRecipientAddress } = config;
2330
2342
  const tokenSymbol = assertTokenSymbolResolved(resolvedSymbol);
2331
2343
  validateBridgeAmount(amount);
2332
2344
  validateRecipientAddress(recipientAddress, "recipient");
@@ -2342,7 +2354,10 @@ async function executeBridgeOutFlow(params, config) {
2342
2354
  recipientAddress,
2343
2355
  tokenDescriptor: metadata.descriptor
2344
2356
  });
2345
- const signedPayload = await buildBridgeOutPayload(dtoPayload, { wallet: ethereumWallet });
2357
+ const signedPayload = await buildBridgeOutPayload(dtoPayload, {
2358
+ wallet: ethereumWallet,
2359
+ eip712DomainName
2360
+ });
2346
2361
  const requestResponse = await galaConnectClient.requestBridgeOut(signedPayload);
2347
2362
  assertRequestAccepted("RequestTokenBridgeOut", requestResponse, signedPayload.uniqueKey);
2348
2363
  const transactionHash = await completeBridgeOut(galaConnectClient, requestResponse, signedPayload.uniqueKey, "asset", extractBridgeOutTransactionHash);
@@ -2809,6 +2824,7 @@ var EthereumBridgeStrategy = class EthereumBridgeStrategy extends ConfiguredBrid
2809
2824
  ethereumBridgeContract;
2810
2825
  ethereumWalletAddress;
2811
2826
  tokenMetadataResolver;
2827
+ eip712DomainName;
2812
2828
  /**
2813
2829
  * Creates a new Ethereum bridge strategy.
2814
2830
  *
@@ -2827,6 +2843,7 @@ var EthereumBridgeStrategy = class EthereumBridgeStrategy extends ConfiguredBrid
2827
2843
  const rpcUrl = assertHttpUrlOption(config.ethereumRpcUrl ?? "https://ethereum.publicnode.com", "ethereumRpcUrl");
2828
2844
  if (config.ethereumWalletAddress !== void 0) assertEthereumAddressOption(config.ethereumWalletAddress, "ethereumWalletAddress");
2829
2845
  this.ethereumProvider = new JsonRpcProvider(rpcUrl);
2846
+ this.eip712DomainName = config.eip712DomainName;
2830
2847
  this.ethereumWallet = new Wallet(config.ethereumPrivateKey, this.ethereumProvider);
2831
2848
  this.ethereumWalletAddress = config.ethereumWalletAddress ?? this.ethereumWallet.address;
2832
2849
  this.ethereumBridgeContract = ethereumBridgeContract;
@@ -2852,6 +2869,7 @@ var EthereumBridgeStrategy = class EthereumBridgeStrategy extends ConfiguredBrid
2852
2869
  galaConnectClient: this.galaConnectClient,
2853
2870
  tokenMetadataResolver: this.tokenMetadataResolver,
2854
2871
  ethereumWallet: this.ethereumWallet,
2872
+ eip712DomainName: this.eip712DomainName,
2855
2873
  destinationChainId: CHAIN_IDS.ETHEREUM,
2856
2874
  destinationChain: "Ethereum",
2857
2875
  validateRecipientAddress: validateEthereumAddressOrThrow
@@ -3213,6 +3231,7 @@ var SolanaBridgeStrategy = class extends ConfiguredBridgeStrategy {
3213
3231
  network = "Solana";
3214
3232
  galaChainWalletAddress;
3215
3233
  ethereumWallet;
3234
+ eip712DomainName;
3216
3235
  solanaConnection;
3217
3236
  solanaKeypair;
3218
3237
  solanaBridgeProgramId;
@@ -3236,6 +3255,7 @@ var SolanaBridgeStrategy = class extends ConfiguredBridgeStrategy {
3236
3255
  this.galaChainWalletAddress = config.galaChainWalletAddress;
3237
3256
  validateEthereumPrivateKeyFormat(config.ethereumPrivateKey);
3238
3257
  this.ethereumWallet = new Wallet(config.ethereumPrivateKey);
3258
+ this.eip712DomainName = config.eip712DomainName;
3239
3259
  const rpcUrl = assertHttpUrlOption(config.solanaRpcUrl ?? "https://api.mainnet-beta.solana.com", "solanaRpcUrl");
3240
3260
  this.solanaConnection = config.solanaConnection ?? new Connection(rpcUrl, "confirmed");
3241
3261
  this.solanaKeypair = keypairFromBase58(config.solanaPrivateKeyBase58);
@@ -3265,6 +3285,7 @@ var SolanaBridgeStrategy = class extends ConfiguredBridgeStrategy {
3265
3285
  galaConnectClient: this.galaConnectClient,
3266
3286
  tokenMetadataResolver: this.tokenMetadataResolver,
3267
3287
  ethereumWallet: this.ethereumWallet,
3288
+ eip712DomainName: this.eip712DomainName,
3268
3289
  destinationChainId: CHAIN_IDS.SOLANA,
3269
3290
  destinationChain: "Solana",
3270
3291
  validateRecipientAddress: validateSolanaAddressOrThrow
@@ -3814,6 +3835,7 @@ var BridgeService = class {
3814
3835
  });
3815
3836
  this.bridgeableTokenService = config.bridgeableTokenService;
3816
3837
  const sleep = config.sleep !== void 0 ? { sleep: config.sleep } : {};
3838
+ const eip712DomainName = config.eip712DomainName ?? urls.eip712DomainName;
3817
3839
  this.strategies = /* @__PURE__ */ new Map([["Ethereum", new EthereumBridgeStrategy({
3818
3840
  galaConnectClient: this.galaConnectClient,
3819
3841
  galaChainWalletAddress,
@@ -3821,6 +3843,7 @@ var BridgeService = class {
3821
3843
  ethereumRpcUrl: config.ethereumRpcUrl ?? rpcUrls.ethereum,
3822
3844
  ethereumBridgeContract: config.ethereumBridgeContract ?? getEthereumBridgeContractByEnvironment(this.environment),
3823
3845
  tokenConfigs: getEthereumTokensByEnvironment(this.environment),
3846
+ eip712DomainName,
3824
3847
  ...sleep
3825
3848
  })]]);
3826
3849
  if (config.solanaPrivateKey !== void 0 && config.solanaPrivateKey !== "") this.strategies.set("Solana", new SolanaBridgeStrategy({
@@ -3831,6 +3854,7 @@ var BridgeService = class {
3831
3854
  solanaRpcUrl: config.solanaRpcUrl ?? rpcUrls.solana,
3832
3855
  solanaBridgeProgram: config.solanaBridgeProgram ?? "AaE4dTnL75XqgUJpdxBKg6vS9sTJgBPJwBQRVhD29WwS",
3833
3856
  tokenConfigs: DEFAULT_SOLANA_TOKENS,
3857
+ eip712DomainName,
3834
3858
  ...config.solanaConnection !== void 0 && { solanaConnection: config.solanaConnection },
3835
3859
  ...sleep
3836
3860
  }));
@@ -4818,5 +4842,5 @@ function stripHexPrefix(hex) {
4818
4842
  }
4819
4843
 
4820
4844
  //#endregion
4821
- export { BRIDGE_CONTRACT_ABI, BaseBridgeStrategy, BridgeService, BridgeStatusCode, BridgeableTokenService, CHAIN_IDS, CROSS_RATE_TYPED_DATA_TYPES, DEFAULT_ETHEREUM_BRIDGE_CONTRACT, DEFAULT_ETHEREUM_RPC_URL, DEFAULT_POLL_INTERVAL_MS, DEFAULT_POLL_TIMEOUT_MS, DEFAULT_RATE_LIMIT_RPS, DEFAULT_SOLANA_BRIDGE_PROGRAM, DEFAULT_SOLANA_RPC_URL, DEFAULT_SOLANA_TOKENS, ERC20_ABI, ETHEREUM_BRIDGE_CONTRACT_SEPOLIA, ETHEREUM_TOKENS_PROD, ETHEREUM_TOKENS_STAGE, EthereumBridgeStrategy, GALACHAIN_CHANNELS, GALACONNECT_PRODUCTION_URL, GALA_BRIDGE_TYPED_DATA_DOMAIN, GalaConnectClient, LEGACY_TYPED_DATA_TYPES, RateLimiter, SOLANA_COMPUTE, SOLANA_DISCRIMINATORS, STATIC_TOKEN_METADATA, SolanaBridgeStrategy, WrapService, WrappableTokenService, buildBridgeOutPayload, compareAmounts, createSolanaWallet, formatTokenAmount, formatTokenDescriptor, fromBaseUnits, getEthereumBridgeContractByEnvironment, getEthereumTokenConfig, getEthereumTokensByEnvironment, getGalaBridgeTypedDataTypes, getSolanaTokenConfig, getStaticTokenMetadata, isValidGalaChainChannel, parseTokenId, parseTokenString, stringifyTokenClassKey, stripHexPrefix, toBaseUnits };
4845
+ export { BRIDGE_CONTRACT_ABI, BaseBridgeStrategy, BridgeService, BridgeStatusCode, BridgeableTokenService, CHAIN_IDS, CROSS_RATE_TYPED_DATA_TYPES, DEFAULT_ETHEREUM_BRIDGE_CONTRACT, DEFAULT_ETHEREUM_RPC_URL, DEFAULT_POLL_INTERVAL_MS, DEFAULT_POLL_TIMEOUT_MS, DEFAULT_RATE_LIMIT_RPS, DEFAULT_SOLANA_BRIDGE_PROGRAM, DEFAULT_SOLANA_RPC_URL, DEFAULT_SOLANA_TOKENS, ERC20_ABI, ETHEREUM_BRIDGE_CONTRACT_SEPOLIA, ETHEREUM_TOKENS_PROD, ETHEREUM_TOKENS_STAGE, EthereumBridgeStrategy, GALACHAIN_CHANNELS, GALACONNECT_PRODUCTION_URL, GALA_BRIDGE_TYPED_DATA_DOMAIN, GalaConnectClient, LEGACY_TYPED_DATA_TYPES, RateLimiter, SOLANA_COMPUTE, SOLANA_DISCRIMINATORS, STATIC_TOKEN_METADATA, SolanaBridgeStrategy, WrapService, WrappableTokenService, buildBridgeOutPayload, compareAmounts, createSolanaWallet, formatTokenAmount, formatTokenDescriptor, fromBaseUnits, galaBridgeTypedDataDomain, getEthereumBridgeContractByEnvironment, getEthereumTokenConfig, getEthereumTokensByEnvironment, getGalaBridgeTypedDataTypes, getSolanaTokenConfig, getStaticTokenMetadata, isValidGalaChainChannel, parseTokenId, parseTokenString, stringifyTokenClassKey, stripHexPrefix, toBaseUnits };
4822
4846
  //# sourceMappingURL=bridge.mjs.map