@tatumio/doge 2.0.1-alpha.203
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/package.json +26 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +5 -0
- package/src/index.js.map +1 -0
- package/src/lib/doge.sdk.d.ts +135 -0
- package/src/lib/doge.sdk.errors.d.ts +10 -0
- package/src/lib/doge.sdk.errors.js +26 -0
- package/src/lib/doge.sdk.errors.js.map +1 -0
- package/src/lib/doge.sdk.js +22 -0
- package/src/lib/doge.sdk.js.map +1 -0
- package/src/lib/doge.sdk.tx.d.ts +4 -0
- package/src/lib/doge.sdk.tx.js +53 -0
- package/src/lib/doge.sdk.tx.js.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tatumio/doge",
|
|
3
|
+
"version": "v2.0.1-alpha.203",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"typings": "./src/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@tatumio/shared-testing": "v2.0.1-alpha.202",
|
|
9
|
+
"@tatumio/shared-blockchain-btc-based": "v2.0.1-alpha.202",
|
|
10
|
+
"@tatumio/shared-core": "v2.0.1-alpha.202",
|
|
11
|
+
"axios": "^0.24.0",
|
|
12
|
+
"@tatumio/api-client": "v2.0.1-alpha.202",
|
|
13
|
+
"cross-blob": "^3.0.0",
|
|
14
|
+
"form-data": "^4.0.0",
|
|
15
|
+
"@tatumio/shared-blockchain-abstract": "v2.0.1-alpha.202",
|
|
16
|
+
"@tatumio/shared-abstract-sdk": "v2.0.1-alpha.202",
|
|
17
|
+
"bignumber.js": "^9.0.2",
|
|
18
|
+
"bip32": "^2.0.5",
|
|
19
|
+
"bip39": "^3.0.2",
|
|
20
|
+
"bitcoinjs-lib": "^5.2.0",
|
|
21
|
+
"hdkey": "^2.0.1",
|
|
22
|
+
"bitcore-lib": "^8.25.25",
|
|
23
|
+
"bitcore-lib-doge": "^8.25.27"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {}
|
|
26
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/doge.sdk';
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/blockchain/doge/src/index.ts"],"names":[],"mappings":";;;AAAA,8DAA8B"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { BlockchainDogecoinService, TatumUrl } from '@tatumio/api-client';
|
|
2
|
+
export declare const TatumDogeSDK: (args: {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
url?: TatumUrl;
|
|
5
|
+
}) => {
|
|
6
|
+
transaction: import("@tatumio/shared-blockchain-btc-based").BtcBasedTx<import("./doge.sdk.tx").DogeTransaction>;
|
|
7
|
+
blockchain: {
|
|
8
|
+
mempool: typeof BlockchainDogecoinService.dogeGetMempool;
|
|
9
|
+
info: typeof BlockchainDogecoinService.dogeGetBlockChainInfo;
|
|
10
|
+
broadcast: typeof BlockchainDogecoinService.dogeBroadcast;
|
|
11
|
+
getBlockHash: typeof BlockchainDogecoinService.dogeGetBlockHash;
|
|
12
|
+
getBlock: typeof BlockchainDogecoinService.dogeGetBlock;
|
|
13
|
+
getUTXO: typeof BlockchainDogecoinService.dogeGetUtxo;
|
|
14
|
+
getTransaction: typeof BlockchainDogecoinService.dogeGetRawTransaction;
|
|
15
|
+
sendTransaction: typeof BlockchainDogecoinService.dogeTransferBlockchain;
|
|
16
|
+
};
|
|
17
|
+
kms: {
|
|
18
|
+
sign(tx: import("@tatumio/shared-core").ChainTransactionKMS, privateKeys: string[]): Promise<string>;
|
|
19
|
+
getAllPending(signatures?: string): import("@tatumio/api-client").CancelablePromise<import("@tatumio/api-client").PendingTransaction>;
|
|
20
|
+
get: typeof import("@tatumio/api-client").SecurityKeyManagementSystemService.getPendingTransactionToSign;
|
|
21
|
+
complete: typeof import("@tatumio/api-client").SecurityKeyManagementSystemService.completePendingSignature;
|
|
22
|
+
delete: typeof import("@tatumio/api-client").SecurityKeyManagementSystemService.deletePendingTransactionToSign;
|
|
23
|
+
};
|
|
24
|
+
wallet: {
|
|
25
|
+
generateAddressFromXPub(xpub: string, i: number, options?: {
|
|
26
|
+
testnet: boolean;
|
|
27
|
+
}): string;
|
|
28
|
+
generatePrivateKeyFromMnemonic(mnemonic: string, i: number, options?: {
|
|
29
|
+
testnet: boolean;
|
|
30
|
+
}): Promise<string>;
|
|
31
|
+
generateAddressFromPrivateKey(privateKey: string, options?: {
|
|
32
|
+
testnet: boolean;
|
|
33
|
+
}): string;
|
|
34
|
+
generateWallet(mnemonic?: string, options?: {
|
|
35
|
+
testnet: boolean;
|
|
36
|
+
}): Promise<import("@tatumio/api-client").TronWallet>;
|
|
37
|
+
};
|
|
38
|
+
offchain: {
|
|
39
|
+
depositAddress: {
|
|
40
|
+
checkExists: (address: string, index?: number) => Promise<import("@tatumio/api-client").Account>;
|
|
41
|
+
create: typeof import("@tatumio/api-client").OffChainAccountService.generateDepositAddress;
|
|
42
|
+
createMultiple: typeof import("@tatumio/api-client").OffChainAccountService.generateDepositAddressesBatch;
|
|
43
|
+
assign: typeof import("@tatumio/api-client").OffChainAccountService.assignAddress;
|
|
44
|
+
remove: typeof import("@tatumio/api-client").OffChainAccountService.removeAddress;
|
|
45
|
+
getByAccount: typeof import("@tatumio/api-client").OffChainAccountService.getAllDepositAddresses;
|
|
46
|
+
};
|
|
47
|
+
withdrawal: {
|
|
48
|
+
getAll: (status?: "InProgress" | "Done" | "Cancelled", pageSize?: number, offset?: number) => Promise<import("@tatumio/api-client").WithdrawalObject[]>;
|
|
49
|
+
};
|
|
50
|
+
storeTokenAddress: typeof import("@tatumio/api-client").OffChainBlockchainService.storeTokenAddress;
|
|
51
|
+
};
|
|
52
|
+
getExchangeRate(basePair?: import("@tatumio/shared-core").Fiat): import("@tatumio/api-client").CancelablePromise<import("@tatumio/api-client").ExchangeRate>;
|
|
53
|
+
storage: {
|
|
54
|
+
upload: typeof import("@tatumio/api-client").StorageIpfsService.storeIpfs;
|
|
55
|
+
get: typeof import("@tatumio/api-client").StorageIpfsService.getIpfsData;
|
|
56
|
+
};
|
|
57
|
+
subscriptions: typeof import("@tatumio/api-client").LedgerSubscriptionService;
|
|
58
|
+
ledger: {
|
|
59
|
+
customer: {
|
|
60
|
+
get: typeof import("@tatumio/api-client").LedgerCustomerService.getCustomerByExternalOrInternalId;
|
|
61
|
+
getAll: typeof import("@tatumio/api-client").LedgerCustomerService.findAllCustomers;
|
|
62
|
+
update: typeof import("@tatumio/api-client").LedgerCustomerService.updateCustomer;
|
|
63
|
+
activate: typeof import("@tatumio/api-client").LedgerCustomerService.activateCustomer;
|
|
64
|
+
deactivate: typeof import("@tatumio/api-client").LedgerCustomerService.deactivateCustomer;
|
|
65
|
+
enable: typeof import("@tatumio/api-client").LedgerCustomerService.enableCustomer;
|
|
66
|
+
disable: typeof import("@tatumio/api-client").LedgerCustomerService.disableCustomer;
|
|
67
|
+
};
|
|
68
|
+
orderBook: {
|
|
69
|
+
getHistorical: typeof import("@tatumio/api-client").LedgerOrderBookService.getHistoricalTradesBody;
|
|
70
|
+
getActiveBuyTrades: typeof import("@tatumio/api-client").LedgerOrderBookService.getBuyTradesBody;
|
|
71
|
+
getActiveSellTrades: typeof import("@tatumio/api-client").LedgerOrderBookService.getBuyTradesBody;
|
|
72
|
+
newTrade: typeof import("@tatumio/api-client").LedgerOrderBookService.storeTrade;
|
|
73
|
+
get: typeof import("@tatumio/api-client").LedgerOrderBookService.getTradeById;
|
|
74
|
+
cancel: typeof import("@tatumio/api-client").LedgerOrderBookService.deleteTrade;
|
|
75
|
+
cancelByAccount: typeof import("@tatumio/api-client").LedgerOrderBookService.deleteAccountTrades;
|
|
76
|
+
};
|
|
77
|
+
transaction: {
|
|
78
|
+
send: typeof import("@tatumio/api-client").LedgerTransactionService.sendTransaction;
|
|
79
|
+
sendMultiple: typeof import("@tatumio/api-client").LedgerTransactionService.sendTransactionBatch;
|
|
80
|
+
getAll: typeof import("@tatumio/api-client").LedgerTransactionService.getTransactions;
|
|
81
|
+
getAllByAccount: typeof import("@tatumio/api-client").LedgerTransactionService.getTransactionsByAccountId;
|
|
82
|
+
getAllByCustomer: typeof import("@tatumio/api-client").LedgerTransactionService.getTransactionsByCustomerId;
|
|
83
|
+
getAllByReference: typeof import("@tatumio/api-client").LedgerTransactionService.getTransactionsByReference;
|
|
84
|
+
countByAccount: (filter: import("@tatumio/api-client").TransactionFilter) => any;
|
|
85
|
+
countByCustomer: (filter: import("@tatumio/api-client").TransactionFilterCustomer) => any;
|
|
86
|
+
};
|
|
87
|
+
virtualCurrency: {
|
|
88
|
+
create: typeof import("@tatumio/api-client").LedgerVirtualCurrencyService.createCurrency;
|
|
89
|
+
mint: typeof import("@tatumio/api-client").LedgerVirtualCurrencyService.mintCurrency;
|
|
90
|
+
revoke: typeof import("@tatumio/api-client").LedgerVirtualCurrencyService.revokeCurrency;
|
|
91
|
+
getByName: typeof import("@tatumio/api-client").LedgerVirtualCurrencyService.getCurrency;
|
|
92
|
+
update: typeof import("@tatumio/api-client").LedgerVirtualCurrencyService.updateCurrency;
|
|
93
|
+
};
|
|
94
|
+
blockAmount: {
|
|
95
|
+
block: typeof import("@tatumio/api-client").LedgerAccountService.blockAmount;
|
|
96
|
+
unblock: typeof import("@tatumio/api-client").LedgerAccountService.deleteBlockAmount;
|
|
97
|
+
unblockWithTransaction: typeof import("@tatumio/api-client").LedgerAccountService.unblockAmountWithTransaction;
|
|
98
|
+
};
|
|
99
|
+
account: {
|
|
100
|
+
get: typeof import("@tatumio/api-client").LedgerAccountService.getAccountByAccountId;
|
|
101
|
+
getAll: typeof import("@tatumio/api-client").LedgerAccountService.getAllAccounts;
|
|
102
|
+
getByCustomerId: typeof import("@tatumio/api-client").LedgerAccountService.getAccountsByCustomerId;
|
|
103
|
+
getBalance: typeof import("@tatumio/api-client").LedgerAccountService.getAccountBalance;
|
|
104
|
+
create: typeof import("@tatumio/api-client").LedgerAccountService.createAccount;
|
|
105
|
+
createMultiple: typeof import("@tatumio/api-client").LedgerAccountService.createAccountBatch;
|
|
106
|
+
update: typeof import("@tatumio/api-client").LedgerAccountService.updateAccountByAccountId;
|
|
107
|
+
getBlockedAmountsByAccountId: typeof import("@tatumio/api-client").LedgerAccountService.getBlockAmountById;
|
|
108
|
+
activate: typeof import("@tatumio/api-client").LedgerAccountService.activateAccount;
|
|
109
|
+
deactivate: typeof import("@tatumio/api-client").LedgerAccountService.deactivateAccount;
|
|
110
|
+
freeze: typeof import("@tatumio/api-client").LedgerAccountService.freezeAccount;
|
|
111
|
+
unfreeze: typeof import("@tatumio/api-client").LedgerAccountService.unfreezeAccount;
|
|
112
|
+
generate: (account: import("@tatumio/api-client").CreateAccount, generateNewWalletFn: any, generateNewWallet?: boolean, testnet?: boolean, webhookUrl?: string) => Promise<any>;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
security: {
|
|
116
|
+
checkMaliciousAddress: typeof import("@tatumio/api-client").SecurityAddressService.checkMalicousAddress;
|
|
117
|
+
};
|
|
118
|
+
tatum: {
|
|
119
|
+
getCredits: typeof import("@tatumio/api-client").TatumServiceService.getCredits;
|
|
120
|
+
getVersion: typeof import("@tatumio/api-client").TatumServiceService.getVersion;
|
|
121
|
+
freezeApiKey: typeof import("@tatumio/api-client").TatumServiceService.freezeApiKey;
|
|
122
|
+
unfreezeApiKey: typeof import("@tatumio/api-client").TatumServiceService.unfreezeApiKey;
|
|
123
|
+
};
|
|
124
|
+
nft: {
|
|
125
|
+
mintNFT: typeof import("@tatumio/api-client").BlockchainNftService.nftMintErc721;
|
|
126
|
+
getNFTTransaction: typeof import("@tatumio/api-client").BlockchainNftService.nftGetTransactErc721;
|
|
127
|
+
getNFTTransactionsByToken: typeof import("@tatumio/api-client").BlockchainNftService.nftGetTransactionByToken;
|
|
128
|
+
getNFTTransactionsByAddress: typeof import("@tatumio/api-client").BlockchainNftService.nftGetTransactionByAddress;
|
|
129
|
+
getNFTsByAddress: typeof import("@tatumio/api-client").BlockchainNftService.nftGetBalanceErc721;
|
|
130
|
+
getNFTProvenanceData: typeof import("@tatumio/api-client").BlockchainNftService.nftGetProvenanceDataErc721;
|
|
131
|
+
getNFTMetadataURI: typeof import("@tatumio/api-client").BlockchainNftService.nftGetMetadataErc721;
|
|
132
|
+
getNFTRoyalty: typeof import("@tatumio/api-client").BlockchainNftService.nftGetRoyaltyErc721;
|
|
133
|
+
prepareAddNFTMinterAbstraction: typeof import("@tatumio/api-client").BlockchainNftService.nftGetRoyaltyErc721;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SdkError, SdkErrorCode } from '@tatumio/shared-abstract-sdk';
|
|
2
|
+
export declare const DOGE_ERRORS_MAPPING: {
|
|
3
|
+
'dogecore.ErrorTransactionFeeErrorTooSmall': SdkErrorCode;
|
|
4
|
+
'dogecore.ErrorTransactionInvalidOutputAmountSum': SdkErrorCode;
|
|
5
|
+
'dogecore.ErrorTransactionFeeErrorDifferent': SdkErrorCode;
|
|
6
|
+
};
|
|
7
|
+
export declare type DogeSdkErrorCode = SdkErrorCode.BTC_FEE_TOO_SMALL | SdkErrorCode.BTC_UTXO_NOT_FOUND | SdkErrorCode.BTC_NOT_ENOUGH_BALANCE;
|
|
8
|
+
export declare class DogeSdkError extends SdkError {
|
|
9
|
+
constructor(error: Error | DogeSdkErrorCode);
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DogeSdkError = exports.DOGE_ERRORS_MAPPING = void 0;
|
|
4
|
+
const shared_abstract_sdk_1 = require("@tatumio/shared-abstract-sdk");
|
|
5
|
+
exports.DOGE_ERRORS_MAPPING = {
|
|
6
|
+
'dogecore.ErrorTransactionFeeErrorTooSmall': shared_abstract_sdk_1.SdkErrorCode.BTC_FEE_TOO_SMALL,
|
|
7
|
+
'dogecore.ErrorTransactionInvalidOutputAmountSum': shared_abstract_sdk_1.SdkErrorCode.BTC_NOT_ENOUGH_BALANCE,
|
|
8
|
+
'dogecore.ErrorTransactionFeeErrorDifferent': shared_abstract_sdk_1.SdkErrorCode.BTC_FEE_TOO_SMALL,
|
|
9
|
+
};
|
|
10
|
+
class DogeSdkError extends shared_abstract_sdk_1.SdkError {
|
|
11
|
+
constructor(error) {
|
|
12
|
+
if (typeof error === 'string') {
|
|
13
|
+
super({
|
|
14
|
+
code: error,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
super({
|
|
19
|
+
originalError: error,
|
|
20
|
+
errorSubstringMapping: exports.DOGE_ERRORS_MAPPING,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.DogeSdkError = DogeSdkError;
|
|
26
|
+
//# sourceMappingURL=doge.sdk.errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doge.sdk.errors.js","sourceRoot":"","sources":["../../../../../../packages/blockchain/doge/src/lib/doge.sdk.errors.ts"],"names":[],"mappings":";;;AAAA,sEAAqE;AAExD,QAAA,mBAAmB,GAAG;IACjC,2CAA2C,EAAE,kCAAY,CAAC,iBAAiB;IAC3E,iDAAiD,EAAE,kCAAY,CAAC,sBAAsB;IACtF,4CAA4C,EAAE,kCAAY,CAAC,iBAAiB;CAC7E,CAAA;AAOD,MAAa,YAAa,SAAQ,8BAAQ;IACxC,YAAY,KAA+B;QACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,KAAK,CAAC;gBACJ,IAAI,EAAE,KAAK;aACZ,CAAC,CAAA;SACH;aAAM;YACL,KAAK,CAAC;gBACJ,aAAa,EAAE,KAAK;gBACpB,qBAAqB,EAAE,2BAAmB;aAC3C,CAAC,CAAA;SACH;IACH,CAAC;CACF;AAbD,oCAaC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TatumDogeSDK = void 0;
|
|
4
|
+
const shared_core_1 = require("@tatumio/shared-core");
|
|
5
|
+
const shared_blockchain_btc_based_1 = require("@tatumio/shared-blockchain-btc-based");
|
|
6
|
+
const api_client_1 = require("@tatumio/api-client");
|
|
7
|
+
const doge_sdk_tx_1 = require("./doge.sdk.tx");
|
|
8
|
+
const blockchain = shared_core_1.Blockchain.DOGE;
|
|
9
|
+
const TatumDogeSDK = (args) => {
|
|
10
|
+
return Object.assign(Object.assign({}, (0, shared_blockchain_btc_based_1.btcBasedSdk)(Object.assign(Object.assign({}, args), { blockchain }))), { transaction: (0, doge_sdk_tx_1.dogeTransactions)(), blockchain: {
|
|
11
|
+
mempool: api_client_1.BlockchainDogecoinService.dogeGetMempool,
|
|
12
|
+
info: api_client_1.BlockchainDogecoinService.dogeGetBlockChainInfo,
|
|
13
|
+
broadcast: api_client_1.BlockchainDogecoinService.dogeBroadcast,
|
|
14
|
+
getBlockHash: api_client_1.BlockchainDogecoinService.dogeGetBlockHash,
|
|
15
|
+
getBlock: api_client_1.BlockchainDogecoinService.dogeGetBlock,
|
|
16
|
+
getUTXO: api_client_1.BlockchainDogecoinService.dogeGetUtxo,
|
|
17
|
+
getTransaction: api_client_1.BlockchainDogecoinService.dogeGetRawTransaction,
|
|
18
|
+
sendTransaction: api_client_1.BlockchainDogecoinService.dogeTransferBlockchain,
|
|
19
|
+
} });
|
|
20
|
+
};
|
|
21
|
+
exports.TatumDogeSDK = TatumDogeSDK;
|
|
22
|
+
//# sourceMappingURL=doge.sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doge.sdk.js","sourceRoot":"","sources":["../../../../../../packages/blockchain/doge/src/lib/doge.sdk.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AACjD,sFAAkE;AAClE,oDAAyE;AACzE,+CAAgD;AAEhD,MAAM,UAAU,GAAG,wBAAU,CAAC,IAAI,CAAA;AAE3B,MAAM,YAAY,GAAG,CAAC,IAAwC,EAAE,EAAE;IACvE,uCACK,IAAA,yCAAW,kCAAM,IAAI,KAAE,UAAU,IAAG,KACvC,WAAW,EAAE,IAAA,8BAAgB,GAAE,EAC/B,UAAU,EAAE;YACV,OAAO,EAAE,sCAAyB,CAAC,cAAc;YACjD,IAAI,EAAE,sCAAyB,CAAC,qBAAqB;YACrD,SAAS,EAAE,sCAAyB,CAAC,aAAa;YAClD,YAAY,EAAE,sCAAyB,CAAC,gBAAgB;YACxD,QAAQ,EAAE,sCAAyB,CAAC,YAAY;YAChD,OAAO,EAAE,sCAAyB,CAAC,WAAW;YAC9C,cAAc,EAAE,sCAAyB,CAAC,qBAAqB;YAC/D,eAAe,EAAE,sCAAyB,CAAC,sBAAsB;SAClE,IACF;AACH,CAAC,CAAA;AAfY,QAAA,YAAY,gBAexB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DogeTransactionUTXO, DogeTransactionUTXOKMS } from '@tatumio/api-client';
|
|
2
|
+
import { BtcBasedTx } from '@tatumio/shared-blockchain-btc-based';
|
|
3
|
+
export declare type DogeTransaction = DogeTransactionUTXO | DogeTransactionUTXOKMS;
|
|
4
|
+
export declare const dogeTransactions: () => BtcBasedTx<DogeTransaction>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dogeTransactions = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
const bitcore_lib_doge_1 = require("bitcore-lib-doge");
|
|
7
|
+
const api_client_1 = require("@tatumio/api-client");
|
|
8
|
+
const shared_abstract_sdk_1 = require("@tatumio/shared-abstract-sdk");
|
|
9
|
+
const doge_sdk_errors_1 = require("./doge.sdk.errors");
|
|
10
|
+
// @TODO add support - by address
|
|
11
|
+
const prepareSignedTransaction = (body) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
|
|
12
|
+
try {
|
|
13
|
+
const { fromUTXO, to, fee, changeAddress } = body;
|
|
14
|
+
const tx = new bitcore_lib_doge_1.Transaction().fee(shared_abstract_sdk_1.amountUtils.toSatoshis(fee)).change(changeAddress);
|
|
15
|
+
const privateKeysToSign = [];
|
|
16
|
+
for (const item of fromUTXO) {
|
|
17
|
+
tx.from({
|
|
18
|
+
txId: item.txHash,
|
|
19
|
+
outputIndex: item.index,
|
|
20
|
+
script: bitcore_lib_doge_1.Script.fromAddress(item.address).toString(),
|
|
21
|
+
satoshis: shared_abstract_sdk_1.amountUtils.toSatoshis(item.value),
|
|
22
|
+
});
|
|
23
|
+
if ('signatureId' in item)
|
|
24
|
+
privateKeysToSign.push(item.signatureId);
|
|
25
|
+
else if ('privateKey' in item)
|
|
26
|
+
privateKeysToSign.push(item.privateKey);
|
|
27
|
+
}
|
|
28
|
+
for (const item of to) {
|
|
29
|
+
tx.to(item.address, shared_abstract_sdk_1.amountUtils.toSatoshis(item.value));
|
|
30
|
+
}
|
|
31
|
+
if (fromUTXO && 'signatureId' in fromUTXO[0] && fromUTXO[0].signatureId) {
|
|
32
|
+
return JSON.stringify({ txData: JSON.stringify(tx), privateKeysToSign });
|
|
33
|
+
}
|
|
34
|
+
for (const pk of privateKeysToSign) {
|
|
35
|
+
tx.sign(bitcore_lib_doge_1.PrivateKey.fromWIF(pk));
|
|
36
|
+
}
|
|
37
|
+
return tx.serialize();
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
throw new doge_sdk_errors_1.DogeSdkError(e);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const sendTransaction = (body) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
|
|
44
|
+
return api_client_1.ApiServices.blockchain.doge.dogeBroadcast({
|
|
45
|
+
txData: yield prepareSignedTransaction(body),
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
const dogeTransactions = () => ({
|
|
49
|
+
sendTransaction,
|
|
50
|
+
prepareSignedTransaction,
|
|
51
|
+
});
|
|
52
|
+
exports.dogeTransactions = dogeTransactions;
|
|
53
|
+
//# sourceMappingURL=doge.sdk.tx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doge.sdk.tx.js","sourceRoot":"","sources":["../../../../../../packages/blockchain/doge/src/lib/doge.sdk.tx.ts"],"names":[],"mappings":";;;;AAAA,aAAa;AACb,uDAAkE;AAClE,oDAK4B;AAE5B,sEAA0D;AAC1D,uDAAgD;AAIhD,iCAAiC;AACjC,MAAM,wBAAwB,GAAG,CAAO,IAAqB,EAAmB,EAAE;IAChF,IAAI;QACF,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,IAAI,CAAA;QACjD,MAAM,EAAE,GAAG,IAAI,8BAAW,EAAE,CAAC,GAAG,CAAC,iCAAW,CAAC,UAAU,CAAC,GAAI,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QAEpF,MAAM,iBAAiB,GAAG,EAAE,CAAA;QAC5B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE;YAC3B,EAAE,CAAC,IAAI,CAAC;gBACN,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,WAAW,EAAE,IAAI,CAAC,KAAK;gBACvB,MAAM,EAAE,yBAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE;gBACnD,QAAQ,EAAE,iCAAW,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;aAC7C,CAAC,CAAA;YACF,IAAI,aAAa,IAAI,IAAI;gBAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;iBAC9D,IAAI,YAAY,IAAI,IAAI;gBAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;SACvE;QAED,KAAK,MAAM,IAAI,IAAI,EAAE,EAAE;YACrB,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,iCAAW,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;SACxD;QAED,IAAI,QAAQ,IAAI,aAAa,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;YACvE,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAA;SACzE;QAED,KAAK,MAAM,EAAE,IAAI,iBAAiB,EAAE;YAClC,EAAE,CAAC,IAAI,CAAC,6BAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;SAChC;QAED,OAAO,EAAE,CAAC,SAAS,EAAE,CAAA;KACtB;IAAC,OAAO,CAAM,EAAE;QACf,MAAM,IAAI,8BAAY,CAAC,CAAC,CAAC,CAAA;KAC1B;AACH,CAAC,CAAA,CAAA;AAED,MAAM,eAAe,GAAG,CAAO,IAAqB,EAA+B,EAAE;IACnF,OAAO,wBAAW,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC;QAC/C,MAAM,EAAE,MAAM,wBAAwB,CAAC,IAAI,CAAC;KAC7C,CAAC,CAAA;AACJ,CAAC,CAAA,CAAA;AAEM,MAAM,gBAAgB,GAAG,GAAgC,EAAE,CAAC,CAAC;IAClE,eAAe;IACf,wBAAwB;CACzB,CAAC,CAAA;AAHW,QAAA,gBAAgB,oBAG3B"}
|