@hyperbridge/sdk 1.5.0-rc0000000001 → 1.5.0-rc0000000002
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/browser/index.d.ts +4 -40
- package/dist/browser/index.js +6 -106
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.d.ts +4 -40
- package/dist/node/index.js +12 -112
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -3479,11 +3479,12 @@ type Params = {
|
|
|
3479
3479
|
* @param params.recipient - Recipient address
|
|
3480
3480
|
* @param params.amount - Amount to teleport
|
|
3481
3481
|
* @param params.timeout - Operation timeout
|
|
3482
|
+
* @param params.extrinsics - An array of SubmittableExtrinsic to prepend to the teleport transaction
|
|
3482
3483
|
* @param params.tokenGatewayAddress - Gateway contract address
|
|
3484
|
+
* @param options - Signer options
|
|
3483
3485
|
* @param params.relayerFee - Fee for the relayer
|
|
3484
3486
|
* @param params.redeem - Whether to redeem on arrival
|
|
3485
3487
|
* @param params.callData - Optional additional call data
|
|
3486
|
-
* @param options - Signer options
|
|
3487
3488
|
* @yields {HyperbridgeTxEvents} Stream of events indicating transaction status
|
|
3488
3489
|
* @throws Error when asset ID is unknown or transaction fails
|
|
3489
3490
|
*/
|
|
@@ -3492,45 +3493,8 @@ declare function teleport(teleport_param: {
|
|
|
3492
3493
|
params: Params;
|
|
3493
3494
|
apiPromise: ApiPromise;
|
|
3494
3495
|
options: Partial<SignerOptions>;
|
|
3496
|
+
extrinsics: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
|
|
3495
3497
|
}): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
3496
|
-
/**
|
|
3497
|
-
* Teleports assets from Substrate to other chains via the token gateway
|
|
3498
|
-
*
|
|
3499
|
-
* Note: There is no guarantee that both Dispatched and Finalized events will be yielded.
|
|
3500
|
-
* Consumers should listen for either one of these events instead of expecting both.
|
|
3501
|
-
*
|
|
3502
|
-
*
|
|
3503
|
-
* @param apiPromise - Polkadot API instance
|
|
3504
|
-
* @param params - Teleport parameters
|
|
3505
|
-
* @param params.symbol - Asset symbol
|
|
3506
|
-
* @param params.destination - Target state machine ID
|
|
3507
|
-
* @param params.recipient - Recipient address
|
|
3508
|
-
* @param params.amount - Amount to teleport
|
|
3509
|
-
* @param params.timeout - Operation timeout
|
|
3510
|
-
* @param params.tokenGatewayAddress - Gateway contract address
|
|
3511
|
-
* @param params.relayerFee - Fee for the relayer
|
|
3512
|
-
* @param params.redeem - Whether to redeem on arrival
|
|
3513
|
-
* @param params.callData - Optional additional call data
|
|
3514
|
-
* @yields {HyperbridgeTxEvents} Stream of events indicating transaction status
|
|
3515
|
-
* @throws Error when asset ID is unknown or transaction fails
|
|
3516
|
-
*/
|
|
3517
|
-
declare function makeTeleportExtrinsics(teleport_param: {
|
|
3518
|
-
params: Params;
|
|
3519
|
-
apiPromise: ApiPromise;
|
|
3520
|
-
}): Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>;
|
|
3521
|
-
/**
|
|
3522
|
-
*
|
|
3523
|
-
* @param extrinsic - SubmittableExtrinsic
|
|
3524
|
-
* @param who - SS58Address
|
|
3525
|
-
* @param options - Signer options
|
|
3526
|
-
* @returns
|
|
3527
|
-
*/
|
|
3528
|
-
declare function submitExtrinsics({ extrinsics: tx, who, options, apiPromise, }: {
|
|
3529
|
-
extrinsics: SubmittableExtrinsic<"promise", any>;
|
|
3530
|
-
apiPromise: ApiPromise;
|
|
3531
|
-
who: string;
|
|
3532
|
-
options: Partial<SignerOptions>;
|
|
3533
|
-
}): ReadableStream<HyperbridgeTxEvents>;
|
|
3534
3498
|
|
|
3535
3499
|
declare enum Chains {
|
|
3536
3500
|
BSC_CHAPEL = "EVM-97",
|
|
@@ -3669,4 +3633,4 @@ declare const popularTokens: {
|
|
|
3669
3633
|
"EVM-130": string[];
|
|
3670
3634
|
};
|
|
3671
3635
|
|
|
3672
|
-
export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type DispatchGet, type DispatchPost, ERC20Method, type EstimateGasCallData, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QuoteNativeResult, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, SubstrateChain, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, type Transaction, USE_ETHERSCAN_CHAINS, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getGasPriceFromEtherscan, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString,
|
|
3636
|
+
export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type DispatchGet, type DispatchPost, ERC20Method, type EstimateGasCallData, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QuoteNativeResult, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, SubstrateChain, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, type Transaction, USE_ETHERSCAN_CHAINS, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getGasPriceFromEtherscan, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, maxBigInt, orderCommitment, popularTokens, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, viemChains };
|
package/dist/browser/index.js
CHANGED
|
@@ -13366,7 +13366,7 @@ async function getPostResponseEventFromTx(client, txHash) {
|
|
|
13366
13366
|
var TeleportParams = Struct({
|
|
13367
13367
|
/// StateMachine
|
|
13368
13368
|
destination: StateMachine,
|
|
13369
|
-
///
|
|
13369
|
+
/// Recipient
|
|
13370
13370
|
recepient: H256,
|
|
13371
13371
|
/// Amount
|
|
13372
13372
|
amount: u128,
|
|
@@ -13397,7 +13397,7 @@ async function fetchLocalAssetId(params) {
|
|
|
13397
13397
|
return null;
|
|
13398
13398
|
}
|
|
13399
13399
|
async function teleport(teleport_param) {
|
|
13400
|
-
const {
|
|
13400
|
+
const { params, apiPromise, extrinsics = [] } = teleport_param;
|
|
13401
13401
|
const substrateComplianceAddr = (address, stateMachine) => {
|
|
13402
13402
|
if (stateMachine.startsWith("EVM-")) return pad(address, { size: 32, dir: "left" });
|
|
13403
13403
|
return address;
|
|
@@ -13421,14 +13421,15 @@ async function teleport(teleport_param) {
|
|
|
13421
13421
|
};
|
|
13422
13422
|
const encoded = TeleportParams.enc(teleportParams);
|
|
13423
13423
|
const fullCallData = new Uint8Array([...scaleEncodedAssetId, ...encoded]);
|
|
13424
|
-
const
|
|
13424
|
+
const token_gateway_extrinsics = apiPromise.tx.tokenGateway.teleport(fullCallData);
|
|
13425
|
+
const tx = extrinsics.length === 0 ? token_gateway_extrinsics : apiPromise.tx.utility.batchAll([...extrinsics, token_gateway_extrinsics]);
|
|
13425
13426
|
let unsub = () => {
|
|
13426
13427
|
};
|
|
13427
13428
|
let closed = false;
|
|
13428
13429
|
const stream = new ReadableStream(
|
|
13429
13430
|
{
|
|
13430
13431
|
async start(controller) {
|
|
13431
|
-
unsub = await tx.signAndSend(who, options, async (result) => {
|
|
13432
|
+
unsub = await tx.signAndSend(teleport_param.who, teleport_param.options, async (result) => {
|
|
13432
13433
|
try {
|
|
13433
13434
|
const { isInBlock, isError, dispatchError, txHash, isFinalized, status } = result;
|
|
13434
13435
|
const events = result.events;
|
|
@@ -13500,107 +13501,6 @@ function readIsmpCommitmentHash(events) {
|
|
|
13500
13501
|
}
|
|
13501
13502
|
}
|
|
13502
13503
|
}
|
|
13503
|
-
async function makeTeleportExtrinsics(teleport_param) {
|
|
13504
|
-
const { params, apiPromise } = teleport_param;
|
|
13505
|
-
const substrateComplianceAddr = (address, stateMachine) => {
|
|
13506
|
-
if (stateMachine.startsWith("EVM-")) return pad(address, { size: 32, dir: "left" });
|
|
13507
|
-
return address;
|
|
13508
|
-
};
|
|
13509
|
-
const assetId = keccakAsU8a(params.symbol);
|
|
13510
|
-
const scaleEncodedAssetId = await fetchLocalAssetId({ api: apiPromise, assetId });
|
|
13511
|
-
if (scaleEncodedAssetId === null) {
|
|
13512
|
-
throw new Error("Unknown asset id provided");
|
|
13513
|
-
}
|
|
13514
|
-
const destination = convertStateMachineIdToEnum(params.destination);
|
|
13515
|
-
const recipient = hexToBytes(substrateComplianceAddr(params.recipient, params.destination));
|
|
13516
|
-
const teleportParams = {
|
|
13517
|
-
destination,
|
|
13518
|
-
recepient: Array.from(recipient),
|
|
13519
|
-
amount: params.amount,
|
|
13520
|
-
timeout: BigInt(params.timeout),
|
|
13521
|
-
tokenGatewayAddress: Array.from(params.tokenGatewayAddress),
|
|
13522
|
-
relayerFee: BigInt(params.relayerFee),
|
|
13523
|
-
redeem: params.redeem,
|
|
13524
|
-
callData: params.callData ? Array.from(params.callData) : void 0
|
|
13525
|
-
};
|
|
13526
|
-
const encoded = TeleportParams.enc(teleportParams);
|
|
13527
|
-
const fullCallData = new Uint8Array([...scaleEncodedAssetId, ...encoded]);
|
|
13528
|
-
return apiPromise.tx.tokenGateway.teleport(fullCallData);
|
|
13529
|
-
}
|
|
13530
|
-
function submitExtrinsics({
|
|
13531
|
-
extrinsics: tx,
|
|
13532
|
-
who,
|
|
13533
|
-
options,
|
|
13534
|
-
apiPromise
|
|
13535
|
-
}) {
|
|
13536
|
-
let unsub = () => {
|
|
13537
|
-
};
|
|
13538
|
-
let closed = false;
|
|
13539
|
-
const stream = new ReadableStream(
|
|
13540
|
-
{
|
|
13541
|
-
async start(controller) {
|
|
13542
|
-
unsub = await tx.signAndSend(who, options, async (result) => {
|
|
13543
|
-
try {
|
|
13544
|
-
const { isInBlock, isError, dispatchError, txHash, isFinalized, status } = result;
|
|
13545
|
-
const events = result.events;
|
|
13546
|
-
if (isError) {
|
|
13547
|
-
console.error("Transaction failed: ", dispatchError);
|
|
13548
|
-
controller.enqueue({ kind: "Error", error: dispatchError });
|
|
13549
|
-
unsub?.();
|
|
13550
|
-
controller.close();
|
|
13551
|
-
closed = true;
|
|
13552
|
-
return;
|
|
13553
|
-
}
|
|
13554
|
-
if (status.type === "Ready") {
|
|
13555
|
-
controller.enqueue({
|
|
13556
|
-
kind: "Ready",
|
|
13557
|
-
transaction_hash: txHash.toHex()
|
|
13558
|
-
});
|
|
13559
|
-
}
|
|
13560
|
-
if (isInBlock || isFinalized) {
|
|
13561
|
-
const commitment_hash = readIsmpCommitmentHash(events);
|
|
13562
|
-
const blockHash = isInBlock ? status.asInBlock.toHex() : status.asFinalized.toHex();
|
|
13563
|
-
if (!commitment_hash) {
|
|
13564
|
-
controller.enqueue({
|
|
13565
|
-
kind: "Error",
|
|
13566
|
-
error: new Error("Commitment Hash missing")
|
|
13567
|
-
});
|
|
13568
|
-
return controller.close();
|
|
13569
|
-
}
|
|
13570
|
-
const header = await apiPromise.rpc.chain.getHeader(blockHash);
|
|
13571
|
-
controller.enqueue({
|
|
13572
|
-
kind: isInBlock ? "Dispatched" : "Finalized",
|
|
13573
|
-
transaction_hash: txHash.toHex(),
|
|
13574
|
-
block_number: header.number.toBigInt(),
|
|
13575
|
-
commitment: commitment_hash
|
|
13576
|
-
});
|
|
13577
|
-
if (isFinalized) {
|
|
13578
|
-
unsub?.();
|
|
13579
|
-
controller.close();
|
|
13580
|
-
closed = true;
|
|
13581
|
-
return;
|
|
13582
|
-
}
|
|
13583
|
-
}
|
|
13584
|
-
} catch (err) {
|
|
13585
|
-
if (closed) {
|
|
13586
|
-
return;
|
|
13587
|
-
}
|
|
13588
|
-
controller.enqueue({
|
|
13589
|
-
kind: "Error",
|
|
13590
|
-
error: String(err)
|
|
13591
|
-
});
|
|
13592
|
-
}
|
|
13593
|
-
});
|
|
13594
|
-
},
|
|
13595
|
-
cancel: () => unsub?.()
|
|
13596
|
-
},
|
|
13597
|
-
{
|
|
13598
|
-
highWaterMark: 3,
|
|
13599
|
-
size: () => 1
|
|
13600
|
-
}
|
|
13601
|
-
);
|
|
13602
|
-
return stream;
|
|
13603
|
-
}
|
|
13604
13504
|
var MultiAccount = Struct({
|
|
13605
13505
|
substrate_account: Bytes(32),
|
|
13606
13506
|
evm_account: Bytes(20),
|
|
@@ -13761,6 +13661,6 @@ async function teleportDot(param_) {
|
|
|
13761
13661
|
return stream;
|
|
13762
13662
|
}
|
|
13763
13663
|
|
|
13764
|
-
export { ADDRESS_ZERO, ChainConfigService, Chains, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, ERC20Method, EvmChain, HyperClientStatus, IndexerClient, IntentGateway, OrderStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, STATE_COMMITMENTS_SLOT, SubstrateChain, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, TokenGateway, USE_ETHERSCAN_CHAINS, WrappedNativeDecimals, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getGasPriceFromEtherscan, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString,
|
|
13664
|
+
export { ADDRESS_ZERO, ChainConfigService, Chains, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, ERC20Method, EvmChain, HyperClientStatus, IndexerClient, IntentGateway, OrderStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, STATE_COMMITMENTS_SLOT, SubstrateChain, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, TokenGateway, USE_ETHERSCAN_CHAINS, WrappedNativeDecimals, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createChain, createEvmChain, createIndexerClient, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getGasPriceFromEtherscan, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, maxBigInt, orderCommitment, popularTokens, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, viemChains };
|
|
13765
13665
|
//# sourceMappingURL=index.js.map
|
|
13766
13666
|
//# sourceMappingURL=index.js.map
|