safeheron-api-sdk-python 1.1.18__py3-none-any.whl
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.
- safeheron_api_sdk_python/api/account_api.py +272 -0
- safeheron_api_sdk_python/api/api_key_management_api.py +18 -0
- safeheron_api_sdk_python/api/coin_api.py +65 -0
- safeheron_api_sdk_python/api/gas_api.py +21 -0
- safeheron_api_sdk_python/api/mpc_sign_api.py +73 -0
- safeheron_api_sdk_python/api/tools_api.py +32 -0
- safeheron_api_sdk_python/api/transaction_api.py +399 -0
- safeheron_api_sdk_python/api/web3_api.py +279 -0
- safeheron_api_sdk_python/api/webhook_api.py +49 -0
- safeheron_api_sdk_python/api/whitelist_api.py +154 -0
- safeheron_api_sdk_python/client.py +28 -0
- safeheron_api_sdk_python/cosigner/co_signer_converter.py +185 -0
- safeheron_api_sdk_python/tools.py +335 -0
- safeheron_api_sdk_python/webhook/webhook_converter.py +58 -0
- safeheron_api_sdk_python-1.1.18.dist-info/METADATA +27 -0
- safeheron_api_sdk_python-1.1.18.dist-info/RECORD +19 -0
- safeheron_api_sdk_python-1.1.18.dist-info/WHEEL +5 -0
- safeheron_api_sdk_python-1.1.18.dist-info/licenses/LICENSE +21 -0
- safeheron_api_sdk_python-1.1.18.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
from safeheron_api_sdk_python.client import *
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ListTransactionsV1Request:
|
|
5
|
+
def __init__(self):
|
|
6
|
+
# Page number, start from 1 (default)
|
|
7
|
+
self.pageNumber = None
|
|
8
|
+
# The number of bars per page, the default is 10, max is 100
|
|
9
|
+
self.pageSize = None
|
|
10
|
+
# Source account key
|
|
11
|
+
self.sourceAccountKey = None
|
|
12
|
+
# Source account type
|
|
13
|
+
self.sourceAccountType = None
|
|
14
|
+
# Destination account key
|
|
15
|
+
self.destinationAccountKey = None
|
|
16
|
+
# Destination account type
|
|
17
|
+
self.destinationAccountType = None
|
|
18
|
+
# Start time for creating a transaction, UNIX timestamp (ms)
|
|
19
|
+
self.createTimeMin = None
|
|
20
|
+
# End time for creating a transaction, UNIX timestamp (ms)
|
|
21
|
+
self.createTimeMax = None
|
|
22
|
+
# Min transaction amount
|
|
23
|
+
self.txAmountMin = None
|
|
24
|
+
# Max transaction amount
|
|
25
|
+
self.txAmountMax = None
|
|
26
|
+
# Coin key, multiple coin keys are separated by commas
|
|
27
|
+
self.coinKey = None
|
|
28
|
+
# Transaction fee coin key, multiple coin keys are separated by commas
|
|
29
|
+
self.feeCoinKey = None
|
|
30
|
+
# Transaction status
|
|
31
|
+
self.transactionStatus = None
|
|
32
|
+
# Transaction substatus
|
|
33
|
+
self.transactionSubStatus = None
|
|
34
|
+
# Min duration for completing a transaction, UNIX timestamp (ms)
|
|
35
|
+
self.completedTimeMin = None
|
|
36
|
+
# Max duration for completing a transaction, UNIX timestamp (ms)
|
|
37
|
+
self.completedTimeMax = None
|
|
38
|
+
# Merchant unique business ID
|
|
39
|
+
self.customerRefId = None
|
|
40
|
+
# Type of actual destination account
|
|
41
|
+
self.realDestinationAccountType = None
|
|
42
|
+
# Filter out custom transaction amounts, excluding transaction records below a certain amount specified in USD from the query results
|
|
43
|
+
self.hideSmallAmountUsd = None
|
|
44
|
+
# Filter transaction history by transaction direction:
|
|
45
|
+
# Default: Retrieve all types of transactions
|
|
46
|
+
# INFLOW: Retrieve inflows
|
|
47
|
+
# OUTFLOW: Retrieve outflows
|
|
48
|
+
# INTERNAL_TRANSFER: Retrieve internal transfers
|
|
49
|
+
self.transactionDirection = None
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ListTransactionsV2Request:
|
|
53
|
+
def __init__(self):
|
|
54
|
+
# Query page direction, NEXT by default
|
|
55
|
+
self.direct = None
|
|
56
|
+
# The number of items to retrieve at a time, default max value is 500
|
|
57
|
+
self.limit = None
|
|
58
|
+
# Txkey of the first transaction record. If the first page has no value, provide the txKey of the last transaction record from the previous result
|
|
59
|
+
self.fromId = None
|
|
60
|
+
# Source account key
|
|
61
|
+
self.sourceAccountKey = None
|
|
62
|
+
# Source account type
|
|
63
|
+
self.sourceAccountType = None
|
|
64
|
+
# Destination account key
|
|
65
|
+
self.destinationAccountKey = None
|
|
66
|
+
# Destination account type
|
|
67
|
+
self.destinationAccountType = None
|
|
68
|
+
# Start time for creating a transaction, UNIX timestamp (ms)
|
|
69
|
+
self.createTimeMin = None
|
|
70
|
+
# End time for creating a transaction, UNIX timestamp (ms)
|
|
71
|
+
self.createTimeMax = None
|
|
72
|
+
# Min transaction amount
|
|
73
|
+
self.txAmountMin = None
|
|
74
|
+
# Max transaction amount
|
|
75
|
+
self.txAmountMax = None
|
|
76
|
+
# Coin key, multiple coin keys are separated by commas
|
|
77
|
+
self.coinKey = None
|
|
78
|
+
# Transaction fee coin key, multiple coin keys are separated by commas
|
|
79
|
+
self.feeCoinKey = None
|
|
80
|
+
# Transaction status
|
|
81
|
+
self.transactionStatus = None
|
|
82
|
+
# Transaction substatus
|
|
83
|
+
self.transactionSubStatus = None
|
|
84
|
+
# Min duration for completing a transaction, UNIX timestamp (ms)
|
|
85
|
+
self.completedTimeMin = None
|
|
86
|
+
# Max duration for completing a transaction, UNIX timestamp (ms)
|
|
87
|
+
self.completedTimeMax = None
|
|
88
|
+
# Merchant unique business ID
|
|
89
|
+
self.customerRefId = None
|
|
90
|
+
# Type of actual destination account
|
|
91
|
+
self.realDestinationAccountType = None
|
|
92
|
+
# Filter out custom transaction amounts, excluding transaction records below a certain amount specified in USD from the query results
|
|
93
|
+
self.hideSmallAmountUsd = None
|
|
94
|
+
# Filter transaction history by transaction direction:
|
|
95
|
+
# Default: Retrieve all types of transactions
|
|
96
|
+
# INFLOW: Retrieve inflows
|
|
97
|
+
# OUTFLOW: Retrieve outflows
|
|
98
|
+
# INTERNAL_TRANSFER: Retrieve internal transfers
|
|
99
|
+
self.transactionDirection = None
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class CreateTransactionRequest:
|
|
103
|
+
def __init__(self):
|
|
104
|
+
# Merchant unique business ID (100 characters max)
|
|
105
|
+
self.customerRefId = None
|
|
106
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
107
|
+
self.customerExt1 = None
|
|
108
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
109
|
+
self.customerExt2 = None
|
|
110
|
+
# Transaction note (180 characters max)
|
|
111
|
+
self.note = None
|
|
112
|
+
# Coin key
|
|
113
|
+
self.coinKey = None
|
|
114
|
+
# Transaction Fee Rate Grade
|
|
115
|
+
# Choose between transaction fees. If the transaction fee rate is preset, it will take priority
|
|
116
|
+
self.txFeeLevel = None
|
|
117
|
+
# Transaction fee rate, either txFeeLevel or feeRateDto
|
|
118
|
+
self.feeRateDto = FeeRateDto()
|
|
119
|
+
# Maximum estimated transaction fee rate for a given transaction
|
|
120
|
+
self.maxTxFeeRate = None
|
|
121
|
+
# Transaction amount
|
|
122
|
+
self.txAmount = None
|
|
123
|
+
# Deduct transaction fee from the transfer amount
|
|
124
|
+
# False by default. If set to true, transaction fee will be deducted from the transfer amount
|
|
125
|
+
# Note: This parameter can only be considered if a transaction’s asset is a base asset, such as ETH or MATIC. If the asset can’t be used for transaction fees, like USDC, this parameter is ignored
|
|
126
|
+
self.treatAsGrossAmount = None
|
|
127
|
+
# Source account key
|
|
128
|
+
self.sourceAccountKey = None
|
|
129
|
+
# Account type
|
|
130
|
+
self.sourceAccountType = None
|
|
131
|
+
# Destination account key
|
|
132
|
+
# Whitelist key if the destination is a whitelisted account;
|
|
133
|
+
# Wallet account key if the destination is a wallet account;
|
|
134
|
+
# No key for unknown address
|
|
135
|
+
self.destinationAccountKey = None
|
|
136
|
+
# Destination account type
|
|
137
|
+
self.destinationAccountType = None
|
|
138
|
+
# If the destinationAccountType is ONE_TIME_ADDRESS, then this field should have a value
|
|
139
|
+
self.destinationAddress = None
|
|
140
|
+
# The memo (up to 100 characters) for the destination address, also known as a comment or tag. This parameter is valid for transactions on the following networks:
|
|
141
|
+
# TON: TON mainnet
|
|
142
|
+
# TON_TESTNET: TON testnet
|
|
143
|
+
self.memo = None
|
|
144
|
+
# Destination Tag
|
|
145
|
+
self.destinationTag = None
|
|
146
|
+
# Bitcoin enabled for RBF (Replace-by-fee is a protocol in the Bitcoin mempool that allows for the replacement of an unconfirmed transaction with another one)
|
|
147
|
+
self.isRbf = None
|
|
148
|
+
# The default setting for the parameter is [true]. This parameter determines whether a transaction can be created when the target address is a smart contract. If set to [false], a transaction can still be created for a contract address
|
|
149
|
+
self.failOnContract = None
|
|
150
|
+
# Default value is true. When initiating and approving transactions, Safeheron assesses the destinationAddress for risk through its AML/KYT service provider. It then decides whether to permit the transaction based on this assessment. By default, if the destination address presents compliance risks, the system prohibits the transaction.
|
|
151
|
+
# If you fully understand the associated risks and still need to transfer funds to this address, you can explicitly set failOnAml to false. In this case, Safeheron will disregard the risk assessment results and allow the transaction to proceed.
|
|
152
|
+
self.failOnAml = None
|
|
153
|
+
# Custom nonce
|
|
154
|
+
self.nonce = None
|
|
155
|
+
# Customizable sequence number on Aptos, similar to the nonce in the EVM.
|
|
156
|
+
self.sequenceNumber = None
|
|
157
|
+
# Balance verification, BALANCE_CHECK by default
|
|
158
|
+
self.balanceVerifyType = None
|
|
159
|
+
|
|
160
|
+
def asDict(self):
|
|
161
|
+
dict = self.__dict__
|
|
162
|
+
dict["feeRateDto"] = dict["feeRateDto"].__dict__
|
|
163
|
+
return dict
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class FeeRateDto:
|
|
167
|
+
def __init__(self):
|
|
168
|
+
# Fee rate: fee per byte for UTXO, gas price for EVM chains, free limit for TRON (optional) and gas price for SUI
|
|
169
|
+
self.feeRate = None
|
|
170
|
+
# EVM gas limit
|
|
171
|
+
self.gasLimit = None
|
|
172
|
+
# EIP-1559 max priority fee
|
|
173
|
+
self.maxPriorityFee = None
|
|
174
|
+
# EIP-1559 max fee
|
|
175
|
+
self.maxFee = None
|
|
176
|
+
# Filecoin gas premium, similar to EIP-1559 max priority fee
|
|
177
|
+
self.gasPremium = None
|
|
178
|
+
# Filecoin gas fee cap, similar to EIP-1559 max fee
|
|
179
|
+
self.gasFeeCap = None
|
|
180
|
+
# SUI gas budget, similar to EIP-1559 max fee
|
|
181
|
+
self.gasBudget = None
|
|
182
|
+
# The gas price the transaction sender is willing to pay, similar to EVM gasPrice
|
|
183
|
+
self.gasUnitPrice = None
|
|
184
|
+
# The maximum number of gas units that the transaction sender is willing to spend to execute the transaction, similar to EVM gasLimit
|
|
185
|
+
self.maxGasAmount = None
|
|
186
|
+
|
|
187
|
+
class CreateTransactionsUTXOMultiDestRequest:
|
|
188
|
+
def __init__(self):
|
|
189
|
+
# Merchant unique business ID (100 characters max)
|
|
190
|
+
self.customerRefId = None
|
|
191
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
192
|
+
self.customerExt1 = None
|
|
193
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
194
|
+
self.customerExt2 = None
|
|
195
|
+
# Transaction note (180 characters max)
|
|
196
|
+
self.note = None
|
|
197
|
+
# Coin key
|
|
198
|
+
self.coinKey = None
|
|
199
|
+
# Transaction Fee Rate Grade
|
|
200
|
+
# Choose between transaction fees. If the transaction fee rate is preset, it will take priority
|
|
201
|
+
self.txFeeLevel = None
|
|
202
|
+
# Transaction fee rate, either txFeeLevel or feeRateDto
|
|
203
|
+
self.feeRateDto = FeeRateDto()
|
|
204
|
+
# Maximum estimated transaction fee rate for a given transaction
|
|
205
|
+
self.maxTxFeeRate = None
|
|
206
|
+
# Source account key
|
|
207
|
+
self.sourceAccountKey = None
|
|
208
|
+
# Account type
|
|
209
|
+
self.sourceAccountType = None
|
|
210
|
+
# Destination address list
|
|
211
|
+
self.destinationAddressList = [DestinationAddress]
|
|
212
|
+
# Destination Tag
|
|
213
|
+
self.destinationTag = None
|
|
214
|
+
# Bitcoin enabled for RBF (Replace-by-fee is a protocol in the Bitcoin mempool that allows for the replacement of an unconfirmed transaction with another one)
|
|
215
|
+
self.isRbf = None
|
|
216
|
+
# Default value is true. When initiating and approving transactions, Safeheron assesses the destinationAddress for risk through its AML/KYT service provider. It then decides whether to permit the transaction based on this assessment. By default, if the destination address presents compliance risks, the system prohibits the transaction.
|
|
217
|
+
# If you fully understand the associated risks and still need to transfer funds to this address, you can explicitly set failOnAml to false. In this case, Safeheron will disregard the risk assessment results and allow the transaction to proceed.
|
|
218
|
+
self.failOnAml = None
|
|
219
|
+
|
|
220
|
+
def asDict(self):
|
|
221
|
+
dict = self.__dict__
|
|
222
|
+
dict["feeRateDto"] = dict["feeRateDto"].__dict__
|
|
223
|
+
destinationAddressList = []
|
|
224
|
+
for item in dict["destinationAddressList"]:
|
|
225
|
+
destinationAddressList.append(item.__dict__)
|
|
226
|
+
dict["destinationAddressList"] = destinationAddressList
|
|
227
|
+
return dict
|
|
228
|
+
|
|
229
|
+
class DestinationAddress:
|
|
230
|
+
def __init__(self):
|
|
231
|
+
# Destination address
|
|
232
|
+
self.address = None
|
|
233
|
+
# Transaction amount
|
|
234
|
+
self.amount = None
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
class RecreateTransactionRequest:
|
|
238
|
+
def __init__(self):
|
|
239
|
+
# Transaction key
|
|
240
|
+
self.txKey = None
|
|
241
|
+
# Transaction hash
|
|
242
|
+
self.txHash = None
|
|
243
|
+
# Coin key
|
|
244
|
+
self.coinKey = None
|
|
245
|
+
# Transaction Fee Rate Grade
|
|
246
|
+
# Choose between transaction fees. If the transaction fee rate is preset, it will take priority
|
|
247
|
+
self.txFeeLevel = None
|
|
248
|
+
# Transaction fee rate, either txFeeLevel or feeRateDto
|
|
249
|
+
self.feeRateDto = FeeRateDto()
|
|
250
|
+
|
|
251
|
+
def asDict(self):
|
|
252
|
+
dict = self.__dict__
|
|
253
|
+
dict["feeRateDto"] = dict["feeRateDto"].__dict__
|
|
254
|
+
return dict
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
class OneTransactionsRequest:
|
|
258
|
+
def __init__(self):
|
|
259
|
+
# Transaction key
|
|
260
|
+
self.txKey = None
|
|
261
|
+
# Merchant unique business ID (100 characters max)
|
|
262
|
+
self.customerRefId = None
|
|
263
|
+
|
|
264
|
+
class ApprovalDetailTransactionsRequest:
|
|
265
|
+
def __init__(self):
|
|
266
|
+
# Transaction key list within 20 transaction keys
|
|
267
|
+
self.txKeyList = None
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class TransactionsFeeRateRequest:
|
|
271
|
+
def __init__(self):
|
|
272
|
+
# Coin key
|
|
273
|
+
self.coinKey = None
|
|
274
|
+
# Transaction hash, pass the original transaction hash when speed up transaction estimation
|
|
275
|
+
self.txHash = None
|
|
276
|
+
# Source account key, required for UTXO-based coins
|
|
277
|
+
self.sourceAccountKey = None
|
|
278
|
+
# Source address are required for TRON when estimating transaction fees. For EVM-based transactions, the source address is required when retrieving the gas limit on the blockchain. Otherwise, a default fixed gas limit value will be returned
|
|
279
|
+
self.sourceAddress = None
|
|
280
|
+
# Destination address is optional for TRON and FIL when estimating transaction fees (although providing it may result in a more accurate fee estimation). For EVM-based transactions, the destination address is required when retrieving the gas limit on the blockchain. Otherwise, a default fixed gas limit value will be returned
|
|
281
|
+
self.destinationAddress = None
|
|
282
|
+
# Destination address list
|
|
283
|
+
self.destinationAddressList = [DestinationAddress]
|
|
284
|
+
# Transfer amount is required to calculate gas limit more accurately when using EVM chains. When using UTXO, providing the amount can estimate transaction fees more accurately. If no amount is provided, the calculation is based on the maximum UTXO quantity. When using SUI, providing the amount can estimate gas budget more accurately
|
|
285
|
+
self.value = None
|
|
286
|
+
|
|
287
|
+
def asDict(self):
|
|
288
|
+
dict = self.__dict__
|
|
289
|
+
destinationAddressList = []
|
|
290
|
+
for item in dict["destinationAddressList"]:
|
|
291
|
+
destinationAddressList.append(item.__dict__)
|
|
292
|
+
dict["destinationAddressList"] = destinationAddressList
|
|
293
|
+
return dict
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
class CancelTransactionRequest:
|
|
297
|
+
def __init__(self):
|
|
298
|
+
# Transaction key
|
|
299
|
+
self.txKey = None
|
|
300
|
+
# Transaction type, TRANSACTION by default
|
|
301
|
+
self.txType = None
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
class CollectionTransactionsUTXORequest:
|
|
305
|
+
def __init__(self):
|
|
306
|
+
# Merchant unique business ID (100 characters max)
|
|
307
|
+
self.customerRefId = None
|
|
308
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
309
|
+
self.customerExt1 = None
|
|
310
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
311
|
+
self.customerExt2 = None
|
|
312
|
+
# Transaction note (180 characters max)
|
|
313
|
+
self.note = None
|
|
314
|
+
# Coin key
|
|
315
|
+
self.coinKey = None
|
|
316
|
+
# Transaction fee rate, the unit is the feeUnit returned by the coin list
|
|
317
|
+
self.txFeeRate = None
|
|
318
|
+
# Transaction Fee Rate Grade
|
|
319
|
+
# Choose between the transaction fee rate. If the transaction fee rate is preset, it will take priority
|
|
320
|
+
self.txFeeLevel = None
|
|
321
|
+
# Maximum estimated transaction fee rate for a given transaction
|
|
322
|
+
self.maxTxFeeRate = None
|
|
323
|
+
# Minimum sweeping amount
|
|
324
|
+
self.minCollectionAmount = None
|
|
325
|
+
# Source account key
|
|
326
|
+
self.sourceAccountKey = None
|
|
327
|
+
# Account type
|
|
328
|
+
self.sourceAccountType = None
|
|
329
|
+
# Destination account key
|
|
330
|
+
self.destinationAccountKey = None
|
|
331
|
+
# Destination account type
|
|
332
|
+
self.destinationAccountType = None
|
|
333
|
+
# If the destinationAccountType is ONE_TIME_ADDRESS, then this field should have a value
|
|
334
|
+
self.destinationAddress = None
|
|
335
|
+
# Destination Tag
|
|
336
|
+
self.destinationTag = None
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
class TransactionApi:
|
|
340
|
+
|
|
341
|
+
def __init__(self, config):
|
|
342
|
+
self.api_client = Client(config)
|
|
343
|
+
|
|
344
|
+
# Transaction List V1
|
|
345
|
+
# Filter transaction history by various conditions. For optimal results, we recommend using the V2 version.
|
|
346
|
+
def list_transactions_v1(self, request: ListTransactionsV1Request):
|
|
347
|
+
return self.api_client.send_request(request, '/v1/transactions/list')
|
|
348
|
+
|
|
349
|
+
# Transaction List V2
|
|
350
|
+
# Filter transaction history by various conditions.
|
|
351
|
+
def list_transactions_v2(self, request: ListTransactionsV2Request):
|
|
352
|
+
return self.api_client.send_request(request, '/v2/transactions/list')
|
|
353
|
+
|
|
354
|
+
# Create a new transaction.
|
|
355
|
+
def create_transactions(self, request: CreateTransactionRequest):
|
|
356
|
+
request.asDict()
|
|
357
|
+
return self.api_client.send_request(request, '/v2/transactions/create')
|
|
358
|
+
|
|
359
|
+
# Create a new transaction.
|
|
360
|
+
|
|
361
|
+
def create_transactions_v3(self, request: CreateTransactionRequest):
|
|
362
|
+
request.asDict()
|
|
363
|
+
return self.api_client.send_request(request, '/v3/transactions/create')
|
|
364
|
+
|
|
365
|
+
# For UTXOs that natively support multiple OUTPUTs, this interface allows a single transaction to transfer funds to multiple destination addresses simultaneously.(To use the Co-Signer, please use version 1.5.9 or higher)
|
|
366
|
+
def create_transactions_UTXO_multiDest(self, request: CreateTransactionsUTXOMultiDestRequest):
|
|
367
|
+
request.asDict()
|
|
368
|
+
return self.api_client.send_request(request, '/v1/transactions/utxo/multidest/create')
|
|
369
|
+
|
|
370
|
+
# Speed up EVM and UTXO-based Transactions
|
|
371
|
+
# Transactions with low transaction fees and those that have been pending for a long time can be sped up. EVM-based and BTC transactions can be sped up through RBF(If 'isRbf' is set to true during transaction creation, the transaction will be accelerated using RBF acceleration. Otherwise, CPFP acceleration will be used.) For other UTXO-based transactions, CPFP will be used.
|
|
372
|
+
def recreate_transactions(self, request: RecreateTransactionRequest):
|
|
373
|
+
request.asDict()
|
|
374
|
+
return self.api_client.send_request(request, '/v2/transactions/recreate')
|
|
375
|
+
|
|
376
|
+
# Retrieve a Transaction
|
|
377
|
+
# To query a transaction, either customerRefId or txKey are required. If both values are provided, the retrieval will be based on the txKey.
|
|
378
|
+
def one_transactions(self, request: OneTransactionsRequest):
|
|
379
|
+
return self.api_client.send_request(request, '/v1/transactions/one')
|
|
380
|
+
|
|
381
|
+
# Retrieve Transaction Approval Details
|
|
382
|
+
# Query approval details of a transaction. Exclusively for transactions using the new advanced transaction policy. Learn more about new advanced transaction policies.
|
|
383
|
+
def approval_detail_transactions(self, request: ApprovalDetailTransactionsRequest):
|
|
384
|
+
return self.api_client.send_request(request, '/v1/transactions/approvalDetail')
|
|
385
|
+
|
|
386
|
+
# Estimate Transaction Fee
|
|
387
|
+
# This interface provides users with an estimated range of transaction fee rates of a given cryptocurrency when creating or speeding up transactions.
|
|
388
|
+
def transaction_fee_rate(self, request: TransactionsFeeRateRequest):
|
|
389
|
+
return self.api_client.send_request(request, '/v2/transactions/getFeeRate')
|
|
390
|
+
|
|
391
|
+
# Cancel Transaction
|
|
392
|
+
# Cancel the authorization-pending transaction and the signing-in-progress transaction.
|
|
393
|
+
def cancel_transactions(self, request: CancelTransactionRequest):
|
|
394
|
+
return self.api_client.send_request(request, '/v1/transactions/cancel')
|
|
395
|
+
|
|
396
|
+
# UTXO-Based Coin Sweeping
|
|
397
|
+
# For multi-address UTXO coins under a wallet account, this interface allows users to collect the balances of certain qualifying addresses into a specified destination address.
|
|
398
|
+
def collectionTransactionsUTXO(self, request: CollectionTransactionsUTXORequest):
|
|
399
|
+
return self.api_client.send_request(request, '/v1/transactions/utxo/collection')
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
from safeheron_api_sdk_python.client import *
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CreateWeb3AccountRequest:
|
|
5
|
+
def __init__(self):
|
|
6
|
+
# Account name, 50 characters max
|
|
7
|
+
self.accountName = None
|
|
8
|
+
# Whether display in Safeheron Console
|
|
9
|
+
# True: not display
|
|
10
|
+
# False: display
|
|
11
|
+
# Default: false
|
|
12
|
+
self.hiddenOnUI = None
|
|
13
|
+
# Merchant unique business ID (100 characters max)
|
|
14
|
+
# The customerRefId uniquely represents a wallet. In the case of duplicate customerRefId values (for example, when resubmitting due to request timeouts or other errors), the data returned by the interface will remain consistent
|
|
15
|
+
self.customerRefId = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class BatchCreateWeb3AccountRequest:
|
|
19
|
+
def __init__(self):
|
|
20
|
+
# The prefix of wallet account name, 50 characters max
|
|
21
|
+
self.accountName = None
|
|
22
|
+
# Whether display in Safeheron Console
|
|
23
|
+
# True: not display
|
|
24
|
+
# False: display
|
|
25
|
+
# Default: false
|
|
26
|
+
self.hiddenOnUI = None
|
|
27
|
+
# Number of wallets to be created, greater than 0, less than 100
|
|
28
|
+
self.count = None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ListWeb3AccountRequest:
|
|
32
|
+
def __init__(self):
|
|
33
|
+
# Query page direction, NEXT by default
|
|
34
|
+
self.direct = None
|
|
35
|
+
# The number of items to retrieve at a time, default max value is 500
|
|
36
|
+
self.limit = None
|
|
37
|
+
# Txkey of the first transaction record. If the first page has no value, provide the txKey of the last transaction record from the previous result
|
|
38
|
+
self.fromId = None
|
|
39
|
+
# Filter the response based on this account name prefix
|
|
40
|
+
self.namePrefix = None
|
|
41
|
+
# Merchant unique business ID (100 characters max)
|
|
42
|
+
self.customerRefId = None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class CreateWeb3EthSignRequest:
|
|
46
|
+
def __init__(self):
|
|
47
|
+
# Source account key
|
|
48
|
+
self.accountKey = None
|
|
49
|
+
# Merchant unique business ID (100 characters max)
|
|
50
|
+
self.customerRefId = None
|
|
51
|
+
# Transaction note (180 characters max)
|
|
52
|
+
self.note = None
|
|
53
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
54
|
+
self.customerExt1 = None
|
|
55
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
56
|
+
self.customerExt2 = None
|
|
57
|
+
# Use custom network
|
|
58
|
+
# False: Use the network supported by Safeheron by default
|
|
59
|
+
# True: Use a custom network added through the Safeheron Browser Extension
|
|
60
|
+
self.useCustomNetwork = None
|
|
61
|
+
# Message Hash
|
|
62
|
+
self.messageHash = self.MessageHash()
|
|
63
|
+
|
|
64
|
+
def asDict(self):
|
|
65
|
+
dict = self.__dict__
|
|
66
|
+
dict["messageHash"] = dict["messageHash"].__dict__
|
|
67
|
+
return dict
|
|
68
|
+
|
|
69
|
+
class MessageHash:
|
|
70
|
+
def __init__(self):
|
|
71
|
+
# Chain ID (does not participate in signing, only the hash is used for signing)
|
|
72
|
+
self.chainId = None
|
|
73
|
+
# Pending signature hash, hexadecimal string (currently only supports one input)
|
|
74
|
+
self.hash = None
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class CreateWeb3PersonalSignRequest:
|
|
78
|
+
def __init__(self):
|
|
79
|
+
# Source account key
|
|
80
|
+
self.accountKey = None
|
|
81
|
+
# Merchant unique business ID (100 characters max)
|
|
82
|
+
self.customerRefId = None
|
|
83
|
+
# Transaction note (180 characters max)
|
|
84
|
+
self.note = None
|
|
85
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
86
|
+
self.customerExt1 = None
|
|
87
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
88
|
+
self.customerExt2 = None
|
|
89
|
+
# Use custom network
|
|
90
|
+
# False: Use the network supported by Safeheron by default
|
|
91
|
+
# True: Use a custom network added through the Safeheron Browser Extension
|
|
92
|
+
self.useCustomNetwork = None
|
|
93
|
+
# Message Hash
|
|
94
|
+
self.message = self.Message()
|
|
95
|
+
|
|
96
|
+
def asDict(self):
|
|
97
|
+
dict = self.__dict__
|
|
98
|
+
dict["message"] = dict["message"].__dict__
|
|
99
|
+
return dict
|
|
100
|
+
|
|
101
|
+
class Message:
|
|
102
|
+
def __init__(self):
|
|
103
|
+
# Chain ID (does not participate in signing, only the hash is used for signing)
|
|
104
|
+
self.chainId = None
|
|
105
|
+
# Data to be signed
|
|
106
|
+
self.data = None
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class CreateWeb3EthSignTypedDataRequest:
|
|
110
|
+
def __init__(self):
|
|
111
|
+
# Source account key
|
|
112
|
+
self.accountKey = None
|
|
113
|
+
# Merchant unique business ID (100 characters max)
|
|
114
|
+
self.customerRefId = None
|
|
115
|
+
# Transaction note (180 characters max)
|
|
116
|
+
self.note = None
|
|
117
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
118
|
+
self.customerExt1 = None
|
|
119
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
120
|
+
self.customerExt2 = None
|
|
121
|
+
# Use custom network
|
|
122
|
+
# False: Use the network supported by Safeheron by default
|
|
123
|
+
# True: Use a custom network added through the Safeheron Browser Extension
|
|
124
|
+
self.useCustomNetwork = None
|
|
125
|
+
# Message Hash
|
|
126
|
+
self.message = self.Message()
|
|
127
|
+
|
|
128
|
+
def asDict(self):
|
|
129
|
+
dict = self.__dict__
|
|
130
|
+
dict["message"] = dict["message"].__dict__
|
|
131
|
+
return dict
|
|
132
|
+
|
|
133
|
+
class Message:
|
|
134
|
+
def __init__(self):
|
|
135
|
+
# Chain ID (does not participate in signing, only the hash is used for signing)
|
|
136
|
+
self.chainId = None
|
|
137
|
+
# Data to be signed
|
|
138
|
+
self.data = None
|
|
139
|
+
# EthSignTypedData Version
|
|
140
|
+
self.version = None
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class CreateWeb3EthSignTransactionRequest:
|
|
144
|
+
def __init__(self):
|
|
145
|
+
# Source account key
|
|
146
|
+
self.accountKey = None
|
|
147
|
+
# Merchant unique business ID (100 characters max)
|
|
148
|
+
self.customerRefId = None
|
|
149
|
+
# Transaction note (180 characters max)
|
|
150
|
+
self.note = None
|
|
151
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
152
|
+
self.customerExt1 = None
|
|
153
|
+
# Merchant extended field (defined by merchant) shown to merchant (255 characters max)
|
|
154
|
+
self.customerExt2 = None
|
|
155
|
+
# Use custom network
|
|
156
|
+
# False: Use the network supported by Safeheron by default
|
|
157
|
+
# True: Use a custom network added through the Safeheron Browser Extension
|
|
158
|
+
self.useCustomNetwork = None
|
|
159
|
+
# Transaction
|
|
160
|
+
self.transaction = self.Transaction()
|
|
161
|
+
|
|
162
|
+
def asDict(self):
|
|
163
|
+
dict = self.__dict__
|
|
164
|
+
dict["transaction"] = dict["transaction"].__dict__
|
|
165
|
+
return dict
|
|
166
|
+
|
|
167
|
+
class Transaction:
|
|
168
|
+
def __init__(self):
|
|
169
|
+
# To
|
|
170
|
+
self.to = None
|
|
171
|
+
# Value (Unit: wei)
|
|
172
|
+
self.value = None
|
|
173
|
+
# Chain ID
|
|
174
|
+
self.chainId = None
|
|
175
|
+
# Gas price
|
|
176
|
+
self.gasPrice = None
|
|
177
|
+
# Gas limit
|
|
178
|
+
self.gasLimit = None
|
|
179
|
+
# Max priority fee per gas for EIP-1559
|
|
180
|
+
self.maxPriorityFeePerGas = None
|
|
181
|
+
# Max fee per gas for EIP-1559
|
|
182
|
+
self.maxFeePerGas = None
|
|
183
|
+
# Nonce
|
|
184
|
+
self.nonce = None
|
|
185
|
+
# Data
|
|
186
|
+
self.data = None
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class CancelWeb3SignRequest:
|
|
190
|
+
def __init__(self):
|
|
191
|
+
# Transaction key
|
|
192
|
+
self.txKey = None
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class OneWeb3SignRequest:
|
|
196
|
+
def __init__(self):
|
|
197
|
+
# Transaction key
|
|
198
|
+
self.txKey = None
|
|
199
|
+
# Merchant unique business ID (100 characters max)
|
|
200
|
+
self.customerRefId = None
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class ListWeb3SignRequest:
|
|
204
|
+
def __init__(self):
|
|
205
|
+
# Query page direction, NEXT by default
|
|
206
|
+
self.direct = None
|
|
207
|
+
# The number of items to retrieve at a time, default max value is 500
|
|
208
|
+
self.limit = None
|
|
209
|
+
# Txkey of the first transaction record. If the first page has no value, provide the txKey of the last transaction record from the previous result
|
|
210
|
+
self.fromId = None
|
|
211
|
+
# Web3 Sign type
|
|
212
|
+
self.subjectType = None
|
|
213
|
+
# Transaction status
|
|
214
|
+
self.transactionStatus = None
|
|
215
|
+
# Source account key
|
|
216
|
+
self.accountKey = None
|
|
217
|
+
# Start time for creating a transaction, UNIX timestamp (ms) (If no value is provided, the default value is createTimeMax minus 24 hours)
|
|
218
|
+
self.createTimeMin = None
|
|
219
|
+
# End time for creating a transaction, UNIX timestamp (ms) (If no value is provided, the default value is the current UTC time)
|
|
220
|
+
self.createTimeMax = None
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class Web3Api:
|
|
224
|
+
|
|
225
|
+
def __init__(self, config):
|
|
226
|
+
self.api_client = Client(config)
|
|
227
|
+
|
|
228
|
+
# Create a Web3 Wallet Account
|
|
229
|
+
def createWeb3Account(self, request: CreateWeb3AccountRequest):
|
|
230
|
+
return self.api_client.send_request(request, '/v1/web3/account/create')
|
|
231
|
+
|
|
232
|
+
# Batch Create Web3 Wallet Accounts
|
|
233
|
+
# Create a batch of wallet accounts based on specified number. Web3 wallet accounts created in batches are not displayed in the Safeheron App by default.
|
|
234
|
+
def batchCreateWeb3Account(self, request: BatchCreateWeb3AccountRequest):
|
|
235
|
+
return self.api_client.send_request(request, '/v1/web3/batch/account/create')
|
|
236
|
+
|
|
237
|
+
# List Web3 Wallet Accounts
|
|
238
|
+
# Filter Web3 wallet account lists by various conditions.
|
|
239
|
+
def listWeb3Accounts(self, request: ListWeb3AccountRequest):
|
|
240
|
+
return self.api_client.send_request(request, '/v1/web3/account/list')
|
|
241
|
+
|
|
242
|
+
# Create ethSign
|
|
243
|
+
# Merchants can initiate an ethSign signature through this interface. The merchant is required to serialize the transaction data, generating a corresponding hash (supporting both 0x and non-0x formatted data). The hash is then submitted through this interface to create a signature, which can be obtained by Retrieve a Single Web3 Signature interface or webhook. From there, merchants can complete the subsequent steps according to their own needs once they have obtained the signature.
|
|
244
|
+
def createWeb3EthSign(self, request: CreateWeb3EthSignRequest):
|
|
245
|
+
request.asDict();
|
|
246
|
+
return self.api_client.send_request(request, '/v1/web3/sign/ethSign')
|
|
247
|
+
|
|
248
|
+
# Create personalSign
|
|
249
|
+
# Merchants can initiate a personalSign signature for any text using this interface. The merchant only needs to prepare the data to be signed and submit it through this interface to create the signature. The resulting signature can then be obtained by Retrieve a Single Web3 Signature interface or via webhook. From there, merchants can complete the subsequent steps according to their own needs once they have obtained the signature.
|
|
250
|
+
def createWeb3PersonalSign(self, request: CreateWeb3PersonalSignRequest):
|
|
251
|
+
request.asDict()
|
|
252
|
+
return self.api_client.send_request(request, '/v1/web3/sign/personalSign')
|
|
253
|
+
|
|
254
|
+
# Create ethSignTypedData
|
|
255
|
+
# Merchants can initiate an ethSignTypedData signature of specific formatted data (supporting data formats of v1, v3, and v4) through this interface. Merchants will need to format their signature data and submit it through the interface. Once the signature is created, the result can be retrieved via Retrieve a Single Web3 Signature interface or webhook. From there, merchants can complete the subsequent steps according to their own needs once they have obtained the signature.
|
|
256
|
+
def createWeb3EthSignTypedData(self, request: CreateWeb3EthSignTypedDataRequest):
|
|
257
|
+
request.asDict()
|
|
258
|
+
return self.api_client.send_request(request, '/v1/web3/sign/ethSignTypedData')
|
|
259
|
+
|
|
260
|
+
# Create ethSignTransaction
|
|
261
|
+
# Merchants can initiate ethSignTransaction signature transactions through this interface. The merchant must prepare transaction-related data, such as from, to, nonce, gas limit, gas price, value, data, and more. Once this data is submitted, a signature is created and the result can be obtained by Retrieve a Single Web3 Signature interface or webhook. From there, merchants can complete the subsequent steps according to their own needs once they have obtained the signature.
|
|
262
|
+
def createWeb3EthSignTransaction(self, request: CreateWeb3EthSignTransactionRequest):
|
|
263
|
+
request.asDict()
|
|
264
|
+
return self.api_client.send_request(request, '/v1/web3/sign/ethSignTransaction')
|
|
265
|
+
|
|
266
|
+
# Cancel Signature
|
|
267
|
+
# Cancel pending signatures.
|
|
268
|
+
def cancelWeb3Sign(self, request: CancelWeb3SignRequest):
|
|
269
|
+
return self.api_client.send_request(request, '/v1/web3/sign/cancel')
|
|
270
|
+
|
|
271
|
+
# Retrieve a Single Web3 Signature
|
|
272
|
+
# To query a transaction, either customerRefId or txKey are required. If both values are provided, the retrieval will be based on the txKey.
|
|
273
|
+
def oneWeb3Sign(self, request: OneWeb3SignRequest):
|
|
274
|
+
return self.api_client.send_request(request, '/v1/web3/sign/one')
|
|
275
|
+
|
|
276
|
+
# Web3 Sign Transaction List
|
|
277
|
+
# Filter Web3 Sign history by various conditions.
|
|
278
|
+
def listWeb3Sign(self, request: ListWeb3SignRequest):
|
|
279
|
+
return self.api_client.send_request(request, '/v1/web3/sign/list')
|