@@ -48,6 +48,7 @@ import {
48
48
DeleteAPIKeyResponse ,
49
49
EthereumInterchainNetwork ,
50
50
BitcoinInterchainNetwork ,
51
+ BinanceInterchainNetwork ,
51
52
SupportedInterchains ,
52
53
InterchainNetworkList ,
53
54
CustomTextFieldOptions ,
@@ -748,8 +749,7 @@ export class DragonchainClient {
748
749
if ( ! process . env . SMART_CONTRACT_ID ) throw new FailureByDesign ( 'PARAM_ERROR' , 'Parameter `smartContractId` is required when not running within a smart contract' ) ;
749
750
options . smartContractId = process . env . SMART_CONTRACT_ID ;
750
751
}
751
- const response = ( await this . get ( `/v1/get/${ options . smartContractId } /${ options . key } ` , false ) ) as unknown ;
752
- return response as string ;
752
+ return ( await this . get ( `/v1/get/${ options . smartContractId } /${ options . key } ` , false ) ) as Response < string > ;
753
753
} ;
754
754
755
755
/**
@@ -1076,6 +1076,127 @@ export class DragonchainClient {
1076
1076
return ( await this . post ( `/v1/interchains/ethereum/${ options . name } /transaction` , body ) ) as Response < PublicBlockchainTransactionResponse > ;
1077
1077
} ;
1078
1078
1079
+ /**
1080
+ * Create (or overwrite) a binance wallet/network for interchain use
1081
+ */
1082
+
1083
+ public createBinanceInterchain = async ( options : {
1084
+ /**
1085
+ * The name of the network to update
1086
+ */
1087
+ name : string ;
1088
+ /**
1089
+ * Whether or not this is a testnet wallet/address. Defaults to True.
1090
+ */
1091
+ testnet ?: boolean ;
1092
+ /**
1093
+ * The base64 or hex encoded private key (or mnemonic) to use. Will automatically generate a random one if not provided
1094
+ */
1095
+ privateKey ?: string ;
1096
+ /**
1097
+ * The endpoint of the binance node to use (i.e. http://my.node.address)
1098
+ */
1099
+ nodeURL ?: string ;
1100
+ /**
1101
+ * The port being used to hit the RPC endpoints (i.e. 27147)
1102
+ */
1103
+ rpcPort ?: number ;
1104
+ /**
1105
+ * The port being used to hit the API endpoints (i.e. 1169)
1106
+ */
1107
+ apiPort ?: number ;
1108
+ } ) => {
1109
+ if ( ! options . name ) throw new FailureByDesign ( 'PARAM_ERROR' , 'Parameter `name` is required' ) ;
1110
+ if ( options . rpcPort && ! Number . isInteger ( options . rpcPort ) ) throw new FailureByDesign ( 'PARAM_ERROR' , 'Parameter `rpcPort` must be an integer' ) ;
1111
+ if ( options . apiPort && ! Number . isInteger ( options . apiPort ) ) throw new FailureByDesign ( 'PARAM_ERROR' , 'Parameter `apiPort` must be an integer' ) ;
1112
+ const body : any = { version : '1' , name : options . name } ;
1113
+ if ( typeof options . testnet === 'boolean' ) body . testnet = options . testnet ;
1114
+ if ( options . privateKey ) body . private_key = options . privateKey ;
1115
+ if ( options . nodeURL ) body . node_url = options . nodeURL ;
1116
+ if ( options . rpcPort ) body . rpc_port = options . rpcPort ;
1117
+ if ( options . rpcPort ) body . api_port = options . apiPort ;
1118
+ return ( await this . post ( `/v1/interchains/binance` , body ) ) as Response < BinanceInterchainNetwork > ;
1119
+ } ;
1120
+
1121
+ /**
1122
+ * Update an existing binance wallet/network for interchain use
1123
+ */
1124
+ public updateBinanceInterchain = async ( options : {
1125
+ /**
1126
+ * The name of the network to update
1127
+ */
1128
+ name : string ;
1129
+ /**
1130
+ * Whether or not this is a testnet wallet/address. Defaults to True.
1131
+ */
1132
+ testnet ?: boolean ;
1133
+ /**
1134
+ * The base64 or hex encoded private key to use. Will automatically generate a random one if not provided
1135
+ */
1136
+ privateKey ?: string ;
1137
+ /**
1138
+ * The endpoint of the binance node to use (i.e. http://my.node.address)
1139
+ */
1140
+ nodeURL ?: string ;
1141
+ /**
1142
+ * The port being used to hit the RPC endpoints (i.e. 27147)
1143
+ */
1144
+ rpcPort ?: number ;
1145
+ /**
1146
+ * The port being used to hit the API endpoints (i.e. 1169)
1147
+ */
1148
+ apiPort ?: number ;
1149
+ } ) => {
1150
+ if ( ! options . name ) throw new FailureByDesign ( 'PARAM_ERROR' , 'Parameter `name` is required' ) ;
1151
+ if ( options . rpcPort && ! Number . isInteger ( options . rpcPort ) ) throw new FailureByDesign ( 'PARAM_ERROR' , 'Parameter `rpcPort` must be an integer' ) ;
1152
+ if ( options . apiPort && ! Number . isInteger ( options . apiPort ) ) throw new FailureByDesign ( 'PARAM_ERROR' , 'Parameter `apiPort` must be an integer' ) ;
1153
+ const body : any = { version : '1' } ;
1154
+ if ( typeof options . testnet === 'boolean' ) body . testnet = options . testnet ;
1155
+ if ( options . privateKey ) body . private_key = options . privateKey ;
1156
+ if ( options . nodeURL ) body . node_url = options . nodeURL ;
1157
+ if ( options . rpcPort ) body . rpc_port = options . rpcPort ;
1158
+ if ( options . apiPort ) body . api_port = options . apiPort ;
1159
+ return ( await this . patch ( `/v1/interchains/binance/${ options . name } ` , body ) ) as Response < BinanceInterchainNetwork > ;
1160
+ } ;
1161
+
1162
+ /**
1163
+ * Create and sign a binance transaction using your chain's interchain network
1164
+ */
1165
+ public signBinanceTransaction = async ( options : {
1166
+ /**
1167
+ * The name of the binance network to use for signing
1168
+ */
1169
+ name : string ;
1170
+ /**
1171
+ * the amount of token to send with this transaction
1172
+ */
1173
+ amount : number ;
1174
+ /**
1175
+ * The (hex-encoded) address to send the transaction to
1176
+ */
1177
+ toAddress : string ;
1178
+ /**
1179
+ * the exchange symbol for the token (defaults to BNB)
1180
+ */
1181
+ symbol ?: string ;
1182
+ /**
1183
+ * string of data to publish in the transaction (defaults to "")
1184
+ */
1185
+ memo ?: string ;
1186
+ } ) => {
1187
+ if ( ! options . name ) throw new FailureByDesign ( 'PARAM_ERROR' , 'Parameter `name` is required' ) ;
1188
+ if ( ! options . amount ) throw new FailureByDesign ( 'PARAM_ERROR' , 'Parameter `amount` is required' ) ;
1189
+ if ( ! options . toAddress ) throw new FailureByDesign ( 'PARAM_ERROR' , 'Parameter `toAddress` is required' ) ;
1190
+ const body : any = {
1191
+ version : '1' ,
1192
+ amount : options . amount ,
1193
+ to_address : options . toAddress
1194
+ } ;
1195
+ if ( options . symbol ) body . symbol = options . symbol ;
1196
+ if ( options . memo ) body . memo = options . memo ;
1197
+ return ( await this . post ( `/v1/interchains/binance/${ options . name } /transaction` , body ) ) as Response < PublicBlockchainTransactionResponse > ;
1198
+ } ;
1199
+
1079
1200
/**
1080
1201
* Get a configured interchain network/wallet from the chain
1081
1202
*/
@@ -1347,7 +1468,7 @@ export class DragonchainClient {
1347
1468
/**
1348
1469
* @hidden
1349
1470
*/
1350
- private generateQueryString = ( queryObject : Map < string , string | number > ) => `?${ UrlSearchParams ( queryObject ) } ` ;
1471
+ private generateQueryString = ( queryObject : Map < string , string | number > ) => ( Object . keys ( queryObject ) . length > 0 ? `?${ UrlSearchParams ( queryObject ) } ` : '' ) ;
1351
1472
1352
1473
/**
1353
1474
* @hidden
0 commit comments