@dfns/sdk 0.2.4 → 0.3.0

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.
@@ -85,7 +85,7 @@ export type BroadcastTransactionRequest = BroadcastTransactionParams & {
85
85
  body: BroadcastTransactionBody;
86
86
  };
87
87
  export type CreateWalletBody = {
88
- network: "ArbitrumOne" | "ArbitrumSepolia" | "AvalancheC" | "AvalancheCFuji" | "Base" | "BaseSepolia" | "Bitcoin" | "BitcoinTestnet3" | "Bsc" | "BscTestnet" | "Ethereum" | "EthereumGoerli" | "EthereumSepolia" | "FantomOpera" | "FantomTestnet" | "Optimism" | "OptimismSepolia" | "Polygon" | "PolygonMumbai" | "ArbitrumGoerli" | "BaseGoerli" | "OptimismGoerli" | "Solana" | "SolanaDevnet" | "Tezos" | "TezosGhostnet" | "Tron" | "TronNile" | "XrpLedger" | "XrpLedgerTestnet" | "KeyEdDSA" | "KeyECDSA" | "KeyECDSAStark";
88
+ network: "ArbitrumOne" | "ArbitrumSepolia" | "AvalancheC" | "AvalancheCFuji" | "Base" | "BaseSepolia" | "Bitcoin" | "BitcoinTestnet3" | "Bsc" | "BscTestnet" | "Ethereum" | "EthereumGoerli" | "EthereumSepolia" | "FantomOpera" | "FantomTestnet" | "Optimism" | "OptimismSepolia" | "Polygon" | "PolygonMumbai" | "Tron" | "TronNile" | "ArbitrumGoerli" | "BaseGoerli" | "OptimismGoerli" | "Solana" | "SolanaDevnet" | "Tezos" | "TezosGhostnet" | "XrpLedger" | "XrpLedgerTestnet" | "KeyEdDSA" | "KeyECDSA" | "KeyECDSAStark";
89
89
  name?: string | undefined;
90
90
  externalId?: string | undefined;
91
91
  tags?: string[] | undefined;
@@ -467,6 +467,7 @@ export type GetWalletAssetsResponse = {
467
467
  assets: {
468
468
  kind: "Native" | "Erc20" | "Erc721" | "Trc10" | "Trc20" | "Trc721";
469
469
  contract?: string | undefined;
470
+ tokenId?: string | undefined;
470
471
  symbol?: string | undefined;
471
472
  decimals: number;
472
473
  verified?: boolean | undefined;
@@ -481,7 +482,7 @@ export type GetWalletHistoryQuery = {
481
482
  limit?: string | undefined;
482
483
  paginationToken?: string | undefined;
483
484
  direction?: ("In" | "Out") | undefined;
484
- kind?: ("NativeTransfer" | "Erc20Transfer" | "Erc721Transfer" | "UtxoTransfer") | undefined;
485
+ kind?: ("NativeTransfer" | "Erc20Transfer" | "Erc721Transfer" | "Trc10Transfer" | "Trc20Transfer" | "Trc721Transfer" | "UtxoTransfer") | undefined;
485
486
  contract?: string | undefined;
486
487
  };
487
488
  export type GetWalletHistoryResponse = {
@@ -598,6 +599,102 @@ export type GetWalletHistoryResponse = {
598
599
  symbol?: string | undefined;
599
600
  /** @deprecated use metadata.asset.verified instead */
600
601
  verified?: boolean | undefined;
602
+ } | {
603
+ walletId: string;
604
+ direction: "In" | "Out";
605
+ network: "ArbitrumOne" | "ArbitrumGoerli" | "ArbitrumSepolia" | "AvalancheC" | "AvalancheCFuji" | "Base" | "BaseGoerli" | "BaseSepolia" | "Bitcoin" | "BitcoinTestnet3" | "Bsc" | "BscTestnet" | "Ethereum" | "EthereumGoerli" | "EthereumSepolia" | "FantomOpera" | "FantomTestnet" | "Optimism" | "OptimismGoerli" | "OptimismSepolia" | "Polygon" | "PolygonMumbai" | "Solana" | "SolanaDevnet" | "Tezos" | "TezosGhostnet" | "Tron" | "TronNile" | "XrpLedger" | "XrpLedgerTestnet" | "KeyECDSA" | "KeyECDSAStark" | "KeyEdDSA";
606
+ blockNumber: number;
607
+ txHash: string;
608
+ index?: string | undefined;
609
+ timestamp: string;
610
+ metadata: {
611
+ asset: {
612
+ symbol?: string | undefined;
613
+ decimals?: number | undefined;
614
+ verified?: boolean | undefined;
615
+ quotes?: {
616
+ [x: string]: number;
617
+ } | undefined;
618
+ };
619
+ fee?: {
620
+ symbol?: string | undefined;
621
+ decimals?: number | undefined;
622
+ verified?: boolean | undefined;
623
+ quotes?: {
624
+ [x: string]: number;
625
+ } | undefined;
626
+ } | undefined;
627
+ };
628
+ kind: "Trc10Transfer";
629
+ tokenId: string;
630
+ from: string;
631
+ to: string;
632
+ value: string;
633
+ fee?: string | undefined;
634
+ } | {
635
+ walletId: string;
636
+ direction: "In" | "Out";
637
+ network: "ArbitrumOne" | "ArbitrumGoerli" | "ArbitrumSepolia" | "AvalancheC" | "AvalancheCFuji" | "Base" | "BaseGoerli" | "BaseSepolia" | "Bitcoin" | "BitcoinTestnet3" | "Bsc" | "BscTestnet" | "Ethereum" | "EthereumGoerli" | "EthereumSepolia" | "FantomOpera" | "FantomTestnet" | "Optimism" | "OptimismGoerli" | "OptimismSepolia" | "Polygon" | "PolygonMumbai" | "Solana" | "SolanaDevnet" | "Tezos" | "TezosGhostnet" | "Tron" | "TronNile" | "XrpLedger" | "XrpLedgerTestnet" | "KeyECDSA" | "KeyECDSAStark" | "KeyEdDSA";
638
+ blockNumber: number;
639
+ txHash: string;
640
+ index?: string | undefined;
641
+ timestamp: string;
642
+ metadata: {
643
+ asset: {
644
+ symbol?: string | undefined;
645
+ decimals?: number | undefined;
646
+ verified?: boolean | undefined;
647
+ quotes?: {
648
+ [x: string]: number;
649
+ } | undefined;
650
+ };
651
+ fee?: {
652
+ symbol?: string | undefined;
653
+ decimals?: number | undefined;
654
+ verified?: boolean | undefined;
655
+ quotes?: {
656
+ [x: string]: number;
657
+ } | undefined;
658
+ } | undefined;
659
+ };
660
+ kind: "Trc20Transfer";
661
+ contract: string;
662
+ from: string;
663
+ to: string;
664
+ value: string;
665
+ fee?: string | undefined;
666
+ } | {
667
+ walletId: string;
668
+ direction: "In" | "Out";
669
+ network: "ArbitrumOne" | "ArbitrumGoerli" | "ArbitrumSepolia" | "AvalancheC" | "AvalancheCFuji" | "Base" | "BaseGoerli" | "BaseSepolia" | "Bitcoin" | "BitcoinTestnet3" | "Bsc" | "BscTestnet" | "Ethereum" | "EthereumGoerli" | "EthereumSepolia" | "FantomOpera" | "FantomTestnet" | "Optimism" | "OptimismGoerli" | "OptimismSepolia" | "Polygon" | "PolygonMumbai" | "Solana" | "SolanaDevnet" | "Tezos" | "TezosGhostnet" | "Tron" | "TronNile" | "XrpLedger" | "XrpLedgerTestnet" | "KeyECDSA" | "KeyECDSAStark" | "KeyEdDSA";
670
+ blockNumber: number;
671
+ txHash: string;
672
+ index?: string | undefined;
673
+ timestamp: string;
674
+ metadata: {
675
+ asset: {
676
+ symbol?: string | undefined;
677
+ decimals?: number | undefined;
678
+ verified?: boolean | undefined;
679
+ quotes?: {
680
+ [x: string]: number;
681
+ } | undefined;
682
+ };
683
+ fee?: {
684
+ symbol?: string | undefined;
685
+ decimals?: number | undefined;
686
+ verified?: boolean | undefined;
687
+ quotes?: {
688
+ [x: string]: number;
689
+ } | undefined;
690
+ } | undefined;
691
+ };
692
+ kind: "Trc721Transfer";
693
+ contract: string;
694
+ from: string;
695
+ to: string;
696
+ tokenId: string;
697
+ fee?: string | undefined;
601
698
  } | {
602
699
  walletId: string;
603
700
  direction: "In" | "Out";
@@ -652,7 +749,7 @@ export type GetWalletNftsResponse = {
652
749
  };
653
750
  export type GetWalletNftsRequest = GetWalletNftsParams;
654
751
  export type ImportWalletBody = {
655
- network: "ArbitrumOne" | "ArbitrumSepolia" | "AvalancheC" | "AvalancheCFuji" | "Base" | "BaseSepolia" | "Bitcoin" | "BitcoinTestnet3" | "Bsc" | "BscTestnet" | "Ethereum" | "EthereumGoerli" | "EthereumSepolia" | "FantomOpera" | "FantomTestnet" | "Optimism" | "OptimismSepolia" | "Polygon" | "PolygonMumbai" | "ArbitrumGoerli" | "BaseGoerli" | "OptimismGoerli" | "Solana" | "SolanaDevnet" | "Tezos" | "TezosGhostnet" | "Tron" | "TronNile" | "XrpLedger" | "XrpLedgerTestnet" | "KeyEdDSA" | "KeyECDSA" | "KeyECDSAStark";
752
+ network: "ArbitrumOne" | "ArbitrumSepolia" | "AvalancheC" | "AvalancheCFuji" | "Base" | "BaseSepolia" | "Bitcoin" | "BitcoinTestnet3" | "Bsc" | "BscTestnet" | "Ethereum" | "EthereumGoerli" | "EthereumSepolia" | "FantomOpera" | "FantomTestnet" | "Optimism" | "OptimismSepolia" | "Polygon" | "PolygonMumbai" | "Tron" | "TronNile" | "ArbitrumGoerli" | "BaseGoerli" | "OptimismGoerli" | "Solana" | "SolanaDevnet" | "Tezos" | "TezosGhostnet" | "XrpLedger" | "XrpLedgerTestnet" | "KeyEdDSA" | "KeyECDSA" | "KeyECDSAStark";
656
753
  name?: string | undefined;
657
754
  externalId?: string | undefined;
658
755
  tags?: string[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfns/sdk",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "dependencies": {
5
5
  "buffer": "6.0.3",
6
6
  "cross-fetch": "3.1.6",
@@ -0,0 +1 @@
1
+ export * from '../generated/permissions/types';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("../generated/permissions/types"), exports);
package/utils/fetch.js CHANGED
@@ -41,6 +41,18 @@ const errorHandler = (fetch) => {
41
41
  }
42
42
  };
43
43
  };
44
+ // raise a 202 response by policy execution as error
45
+ const catchPolicyPending = (fetch) => {
46
+ return async (resource, options) => {
47
+ const response = await fetch(resource, options);
48
+ if (response.status === dfnsError_1.PolicyPendingError.HTTP_ACCEPTED) {
49
+ throw new dfnsError_1.PolicyPendingError(await response.json());
50
+ }
51
+ else {
52
+ return response;
53
+ }
54
+ };
55
+ };
44
56
  const dfnsAuth = (fetch) => {
45
57
  return async (resource, options) => {
46
58
  const { appId, appSecret, authToken } = options.apiOptions;
@@ -90,5 +102,5 @@ const userAction = (fetch) => {
90
102
  return fetch(resource, options);
91
103
  };
92
104
  };
93
- exports.simpleFetch = fullUrl(jsonSerializer(dfnsAuth(errorHandler(cross_fetch_1.fetch))));
94
- exports.userActionFetch = fullUrl(jsonSerializer(dfnsAuth(userAction(errorHandler(cross_fetch_1.fetch)))));
105
+ exports.simpleFetch = fullUrl(jsonSerializer(dfnsAuth(catchPolicyPending(errorHandler(cross_fetch_1.fetch)))));
106
+ exports.userActionFetch = fullUrl(jsonSerializer(dfnsAuth(userAction(catchPolicyPending(errorHandler(cross_fetch_1.fetch))))));