@circle-fin/daa-react-native-sdk 0.0.0-stage → 0.4.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.
- package/DaaReactNativeSdk.podspec +63 -0
- package/LICENSE +176 -0
- package/README.md +217 -2
- package/android/build.gradle +97 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationExceptions.kt +47 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationModule.kt +121 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaScaExceptions.kt +60 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaScaModule.kt +179 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyExceptions.kt +73 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +185 -0
- package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +73 -0
- package/android/src/main/java/com/circle/daa/reactnative/UnpaddedBase64Url.kt +45 -0
- package/build/DaaClient.d.ts +57 -0
- package/build/DaaClient.js +158 -0
- package/build/api/AccountLimitsClient.d.ts +79 -0
- package/build/api/AccountLimitsClient.js +142 -0
- package/build/api/AccountsClient.d.ts +95 -0
- package/build/api/AccountsClient.js +276 -0
- package/build/api/AchFiatAccountsClient.d.ts +92 -0
- package/build/api/AchFiatAccountsClient.js +142 -0
- package/build/api/AuthClient.d.ts +120 -0
- package/build/api/AuthClient.js +257 -0
- package/build/api/DaaUserClient.d.ts +124 -0
- package/build/api/DaaUserClient.js +245 -0
- package/build/api/DepositAddressesClient.d.ts +112 -0
- package/build/api/DepositAddressesClient.js +222 -0
- package/build/api/DepositsClient.d.ts +106 -0
- package/build/api/DepositsClient.js +183 -0
- package/build/api/FiatAccountsClient.d.ts +43 -0
- package/build/api/FiatAccountsClient.js +46 -0
- package/build/api/TransactionsClient.d.ts +64 -0
- package/build/api/TransactionsClient.js +120 -0
- package/build/api/TransfersClient.d.ts +104 -0
- package/build/api/TransfersClient.js +321 -0
- package/build/api/WireFiatAccountsClient.d.ts +99 -0
- package/build/api/WireFiatAccountsClient.js +156 -0
- package/build/api/WithdrawalsClient.d.ts +94 -0
- package/build/api/WithdrawalsClient.js +305 -0
- package/build/api/loginFailure.d.ts +43 -0
- package/build/api/loginFailure.js +64 -0
- package/build/api/pagination.d.ts +29 -0
- package/build/api/pagination.js +50 -0
- package/build/api/queryParameters.d.ts +23 -0
- package/build/api/queryParameters.js +77 -0
- package/build/api/resourceRequest.d.ts +60 -0
- package/build/api/resourceRequest.js +79 -0
- package/build/api/signedResource.d.ts +77 -0
- package/build/api/signedResource.js +168 -0
- package/build/auth/RegistrationFlowKey.d.ts +93 -0
- package/build/auth/RegistrationFlowKey.js +203 -0
- package/build/auth/daaRegistrationNative.d.ts +80 -0
- package/build/auth/daaRegistrationNative.js +184 -0
- package/build/auth/deviceAuthorization.d.ts +73 -0
- package/build/auth/deviceAuthorization.js +243 -0
- package/build/auth/ownerGrant.d.ts +29 -0
- package/build/auth/ownerGrant.js +90 -0
- package/build/auth/prepareReceipt.d.ts +150 -0
- package/build/auth/prepareReceipt.js +357 -0
- package/build/auth/registrationAuthorization.d.ts +48 -0
- package/build/auth/registrationAuthorization.js +243 -0
- package/build/auth/registrationCodeVerifier.d.ts +31 -0
- package/build/auth/registrationCodeVerifier.js +75 -0
- package/build/config.d.ts +79 -0
- package/build/config.js +116 -0
- package/build/crypto/base64url.d.ts +26 -0
- package/build/crypto/base64url.js +87 -0
- package/build/crypto/bytes.d.ts +27 -0
- package/build/crypto/bytes.js +32 -0
- package/build/crypto/es256Jws.d.ts +56 -0
- package/build/crypto/es256Jws.js +196 -0
- package/build/crypto/jwkThumbprint.d.ts +32 -0
- package/build/crypto/jwkThumbprint.js +49 -0
- package/build/crypto/random.d.ts +35 -0
- package/build/crypto/random.js +106 -0
- package/build/crypto/serialization.d.ts +26 -0
- package/build/crypto/serialization.js +43 -0
- package/build/crypto/sha256.d.ts +18 -0
- package/build/crypto/sha256.js +100 -0
- package/build/errors.d.ts +190 -0
- package/build/errors.js +252 -0
- package/build/index.d.ts +61 -0
- package/build/index.js +67 -0
- package/build/models/Account.d.ts +201 -0
- package/build/models/Account.js +147 -0
- package/build/models/AccountLimitsUsage.d.ts +169 -0
- package/build/models/AccountLimitsUsage.js +86 -0
- package/build/models/Ach.d.ts +135 -0
- package/build/models/Ach.js +184 -0
- package/build/models/AddressObject.d.ts +128 -0
- package/build/models/AddressObject.js +141 -0
- package/build/models/BusinessPii.d.ts +84 -0
- package/build/models/BusinessPii.js +142 -0
- package/build/models/CreateAccountRequest.d.ts +74 -0
- package/build/models/CreateAccountRequest.js +19 -0
- package/build/models/CreateTransferRequest.d.ts +91 -0
- package/build/models/CreateTransferRequest.js +19 -0
- package/build/models/CreateWithdrawalRequest.d.ts +99 -0
- package/build/models/CreateWithdrawalRequest.js +19 -0
- package/build/models/DaaUserContext.d.ts +96 -0
- package/build/models/DaaUserContext.js +133 -0
- package/build/models/Deposit.d.ts +241 -0
- package/build/models/Deposit.js +149 -0
- package/build/models/DepositSummary.d.ts +91 -0
- package/build/models/DepositSummary.js +114 -0
- package/build/models/FiatAccount.d.ts +99 -0
- package/build/models/FiatAccount.js +151 -0
- package/build/models/GenerateAddressRequest.d.ts +67 -0
- package/build/models/GenerateAddressRequest.js +68 -0
- package/build/models/Money.d.ts +76 -0
- package/build/models/Money.js +99 -0
- package/build/models/Page.d.ts +33 -0
- package/build/models/Page.js +57 -0
- package/build/models/PendingDeviceRegistration.d.ts +90 -0
- package/build/models/PendingDeviceRegistration.js +180 -0
- package/build/models/PreparedSocialLogin.d.ts +155 -0
- package/build/models/PreparedSocialLogin.js +235 -0
- package/build/models/Transaction.d.ts +187 -0
- package/build/models/Transaction.js +134 -0
- package/build/models/Transfer.d.ts +335 -0
- package/build/models/Transfer.js +240 -0
- package/build/models/Wire.d.ts +213 -0
- package/build/models/Wire.js +264 -0
- package/build/models/Withdrawal.d.ts +201 -0
- package/build/models/Withdrawal.js +156 -0
- package/build/models/redaction.d.ts +18 -0
- package/build/models/redaction.js +23 -0
- package/build/sca/ScaClient.d.ts +105 -0
- package/build/sca/ScaClient.js +193 -0
- package/build/securekey/InMemorySecureKey.d.ts +23 -0
- package/build/securekey/InMemorySecureKey.js +127 -0
- package/build/securekey/NativeSecureKey.d.ts +24 -0
- package/build/securekey/NativeSecureKey.js +178 -0
- package/build/securekey/NativeSecureKeyBridge.d.ts +83 -0
- package/build/securekey/NativeSecureKeyBridge.js +19 -0
- package/build/securekey/SecureKey.d.ts +137 -0
- package/build/securekey/SecureKey.js +19 -0
- package/build/securekey/alias.d.ts +88 -0
- package/build/securekey/alias.js +175 -0
- package/build/securekey/ownerAuthKeyResolver.d.ts +56 -0
- package/build/securekey/ownerAuthKeyResolver.js +63 -0
- package/build/securekey/resolveNativeBridge.d.ts +30 -0
- package/build/securekey/resolveNativeBridge.js +120 -0
- package/build/testing.d.ts +18 -0
- package/build/testing.js +34 -0
- package/build/transport/DaaTransport.d.ts +35 -0
- package/build/transport/DaaTransport.js +19 -0
- package/build/transport/headers.d.ts +30 -0
- package/build/transport/headers.js +45 -0
- package/build/validation/requestBody.d.ts +27 -0
- package/build/validation/requestBody.js +56 -0
- package/build/validation/uuid.d.ts +25 -0
- package/build/validation/uuid.js +33 -0
- package/build/wire/accountLimitsUsagePayload.d.ts +30 -0
- package/build/wire/accountLimitsUsagePayload.js +130 -0
- package/build/wire/accountPayload.d.ts +36 -0
- package/build/wire/accountPayload.js +100 -0
- package/build/wire/achPayload.d.ts +24 -0
- package/build/wire/achPayload.js +82 -0
- package/build/wire/addressObjectPayload.d.ts +44 -0
- package/build/wire/addressObjectPayload.js +64 -0
- package/build/wire/daaStatusCodes.d.ts +64 -0
- package/build/wire/daaStatusCodes.js +69 -0
- package/build/wire/dataEnvelope.d.ts +40 -0
- package/build/wire/dataEnvelope.js +79 -0
- package/build/wire/depositPayload.d.ts +42 -0
- package/build/wire/depositPayload.js +159 -0
- package/build/wire/deviceContextPayload.d.ts +33 -0
- package/build/wire/deviceContextPayload.js +57 -0
- package/build/wire/deviceRegistrationResultPayload.d.ts +32 -0
- package/build/wire/deviceRegistrationResultPayload.js +128 -0
- package/build/wire/errorEnvelope.d.ts +43 -0
- package/build/wire/errorEnvelope.js +85 -0
- package/build/wire/fiatAccountPayload.d.ts +37 -0
- package/build/wire/fiatAccountPayload.js +93 -0
- package/build/wire/instant.d.ts +27 -0
- package/build/wire/instant.js +91 -0
- package/build/wire/jsonNumber.d.ts +30 -0
- package/build/wire/jsonNumber.js +34 -0
- package/build/wire/moneyPayload.d.ts +30 -0
- package/build/wire/moneyPayload.js +56 -0
- package/build/wire/paginationLinks.d.ts +28 -0
- package/build/wire/paginationLinks.js +167 -0
- package/build/wire/payload.d.ts +60 -0
- package/build/wire/payload.js +121 -0
- package/build/wire/pendingRegistrationPayload.d.ts +32 -0
- package/build/wire/pendingRegistrationPayload.js +54 -0
- package/build/wire/socialLoginRequestPayload.d.ts +31 -0
- package/build/wire/socialLoginRequestPayload.js +72 -0
- package/build/wire/transactionPayload.d.ts +31 -0
- package/build/wire/transactionPayload.js +126 -0
- package/build/wire/transferPayload.d.ts +43 -0
- package/build/wire/transferPayload.js +218 -0
- package/build/wire/wireEnums.d.ts +22 -0
- package/build/wire/wireEnums.js +69 -0
- package/build/wire/wirePayload.d.ts +29 -0
- package/build/wire/wirePayload.js +138 -0
- package/build/wire/withdrawalPayload.d.ts +27 -0
- package/build/wire/withdrawalPayload.js +179 -0
- package/expo-module.config.json +14 -0
- package/ios/DaaRegistrationExceptions.swift +58 -0
- package/ios/DaaRegistrationModule.swift +143 -0
- package/ios/DaaScaExceptions.swift +96 -0
- package/ios/DaaScaModule.swift +125 -0
- package/ios/DaaSecureKeyExceptions.swift +77 -0
- package/ios/DaaSecureKeyModule.swift +162 -0
- package/ios/InstallationIdentityStore.swift +126 -0
- package/ios/UnpaddedBase64URL.swift +42 -0
- package/package.json +114 -4
- package/src/DaaClient.ts +171 -0
- package/src/api/AccountLimitsClient.ts +146 -0
- package/src/api/AccountsClient.ts +305 -0
- package/src/api/AchFiatAccountsClient.ts +147 -0
- package/src/api/AuthClient.ts +331 -0
- package/src/api/DaaUserClient.ts +270 -0
- package/src/api/DepositAddressesClient.ts +239 -0
- package/src/api/DepositsClient.ts +208 -0
- package/src/api/FiatAccountsClient.ts +50 -0
- package/src/api/TransactionsClient.ts +137 -0
- package/src/api/TransfersClient.ts +361 -0
- package/src/api/WireFiatAccountsClient.ts +172 -0
- package/src/api/WithdrawalsClient.ts +339 -0
- package/src/api/loginFailure.ts +75 -0
- package/src/api/pagination.ts +63 -0
- package/src/api/queryParameters.ts +82 -0
- package/src/api/resourceRequest.ts +135 -0
- package/src/api/signedResource.ts +267 -0
- package/src/auth/RegistrationFlowKey.ts +274 -0
- package/src/auth/daaRegistrationNative.ts +236 -0
- package/src/auth/deviceAuthorization.ts +302 -0
- package/src/auth/ownerGrant.ts +102 -0
- package/src/auth/prepareReceipt.ts +522 -0
- package/src/auth/registrationAuthorization.ts +306 -0
- package/src/auth/registrationCodeVerifier.ts +76 -0
- package/src/config.ts +156 -0
- package/src/crypto/base64url.ts +88 -0
- package/src/crypto/bytes.ts +30 -0
- package/src/crypto/es256Jws.ts +240 -0
- package/src/crypto/jwkThumbprint.ts +65 -0
- package/src/crypto/random.ts +113 -0
- package/src/crypto/serialization.ts +42 -0
- package/src/crypto/sha256.ts +105 -0
- package/src/errors.ts +319 -0
- package/src/index.ts +223 -0
- package/src/models/Account.ts +264 -0
- package/src/models/AccountLimitsUsage.ts +192 -0
- package/src/models/Ach.ts +269 -0
- package/src/models/AddressObject.ts +169 -0
- package/src/models/BusinessPii.ts +154 -0
- package/src/models/CreateAccountRequest.ts +109 -0
- package/src/models/CreateTransferRequest.ts +114 -0
- package/src/models/CreateWithdrawalRequest.ts +120 -0
- package/src/models/DaaUserContext.ts +172 -0
- package/src/models/Deposit.ts +307 -0
- package/src/models/DepositSummary.ts +142 -0
- package/src/models/FiatAccount.ts +195 -0
- package/src/models/GenerateAddressRequest.ts +101 -0
- package/src/models/Money.ts +91 -0
- package/src/models/Page.ts +48 -0
- package/src/models/PendingDeviceRegistration.ts +197 -0
- package/src/models/PreparedSocialLogin.ts +287 -0
- package/src/models/Transaction.ts +247 -0
- package/src/models/Transfer.ts +459 -0
- package/src/models/Wire.ts +405 -0
- package/src/models/Withdrawal.ts +283 -0
- package/src/models/redaction.ts +22 -0
- package/src/sca/ScaClient.ts +289 -0
- package/src/securekey/InMemorySecureKey.ts +138 -0
- package/src/securekey/NativeSecureKey.ts +179 -0
- package/src/securekey/NativeSecureKeyBridge.ts +109 -0
- package/src/securekey/SecureKey.ts +149 -0
- package/src/securekey/alias.ts +204 -0
- package/src/securekey/ownerAuthKeyResolver.ts +96 -0
- package/src/securekey/resolveNativeBridge.ts +185 -0
- package/src/testing.ts +32 -0
- package/src/transport/DaaTransport.ts +42 -0
- package/src/transport/headers.ts +46 -0
- package/src/validation/requestBody.ts +60 -0
- package/src/validation/uuid.ts +31 -0
- package/src/wire/accountLimitsUsagePayload.ts +182 -0
- package/src/wire/accountPayload.ts +108 -0
- package/src/wire/achPayload.ts +98 -0
- package/src/wire/addressObjectPayload.ts +64 -0
- package/src/wire/daaStatusCodes.ts +69 -0
- package/src/wire/dataEnvelope.ts +80 -0
- package/src/wire/depositPayload.ts +186 -0
- package/src/wire/deviceContextPayload.ts +58 -0
- package/src/wire/deviceRegistrationResultPayload.ts +153 -0
- package/src/wire/errorEnvelope.ts +87 -0
- package/src/wire/fiatAccountPayload.ts +112 -0
- package/src/wire/instant.ts +93 -0
- package/src/wire/jsonNumber.ts +33 -0
- package/src/wire/moneyPayload.ts +55 -0
- package/src/wire/paginationLinks.ts +204 -0
- package/src/wire/payload.ts +146 -0
- package/src/wire/pendingRegistrationPayload.ts +75 -0
- package/src/wire/socialLoginRequestPayload.ts +89 -0
- package/src/wire/transactionPayload.ts +145 -0
- package/src/wire/transferPayload.ts +249 -0
- package/src/wire/wireEnums.ts +74 -0
- package/src/wire/wirePayload.ts +160 -0
- package/src/wire/withdrawalPayload.ts +219 -0
- package/testing.d.ts +19 -0
- package/testing.js +25 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import type { Money } from './Money';
|
|
19
|
+
/**
|
|
20
|
+
* Where a transfer is in its lifecycle (OpenAPI `TransferStatus`, wire values
|
|
21
|
+
* are the enum constant names verbatim).
|
|
22
|
+
*
|
|
23
|
+
* `pending` also covers any asynchronous processing before settlement: the
|
|
24
|
+
* public contract has no intermediate state, so that phase folds into
|
|
25
|
+
* `pending` before this SDK ever sees it.
|
|
26
|
+
*/
|
|
27
|
+
export type TransferStatus = {
|
|
28
|
+
readonly kind: 'pending';
|
|
29
|
+
}
|
|
30
|
+
/** Terminal: successfully settled. */
|
|
31
|
+
| {
|
|
32
|
+
readonly kind: 'complete';
|
|
33
|
+
}
|
|
34
|
+
/** Terminal: failed or denied — see {@link TransferErrorCode}. */
|
|
35
|
+
| {
|
|
36
|
+
readonly kind: 'failed';
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: 'unrecognized';
|
|
39
|
+
readonly rawValue: string | null;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Why a transfer failed (OpenAPI `TransferErrorCode`), present only when
|
|
43
|
+
* {@link TransferStatus} is `failed`.
|
|
44
|
+
*
|
|
45
|
+
* This is the service's own public subset: internal failure reasons fold into
|
|
46
|
+
* `transfer_failed` before they reach the wire.
|
|
47
|
+
* Still modeled as an open set here rather than trusted to stay exactly five
|
|
48
|
+
* values — the public enum can grow without this SDK's say-so, and a value it has
|
|
49
|
+
* not shipped for must read as `unrecognized`, not fail the transfer.
|
|
50
|
+
*/
|
|
51
|
+
export type TransferErrorCode = {
|
|
52
|
+
readonly kind: 'transfer_failed';
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: 'transfer_denied';
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: 'blockchain_error';
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: 'insufficient_funds';
|
|
59
|
+
} | {
|
|
60
|
+
readonly kind: 'invalid_crypto_address';
|
|
61
|
+
} | {
|
|
62
|
+
readonly kind: 'unrecognized';
|
|
63
|
+
readonly rawValue: string | null;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* A transfer's source leg (OpenAPI `TransferSourceLocation`, a `oneOf` of
|
|
67
|
+
* `TransferSourceAccountLocation` and `TransferSourceBlockchainLocation`).
|
|
68
|
+
*
|
|
69
|
+
* Neither source shape ever carries an address: `TransferSourceAccountLocation`
|
|
70
|
+
* has only `id`, and `TransferSourceBlockchainLocation` has only `chain` — a
|
|
71
|
+
* transfer's origin address is not part of the public contract. Both are safe as
|
|
72
|
+
* plain frozen literals, unlike the destination union below, because neither
|
|
73
|
+
* carries a value this SDK must redact.
|
|
74
|
+
*
|
|
75
|
+
* The wire discriminator is the location's shared `type` property, keyed here
|
|
76
|
+
* to `account` / `blockchain` — the only two location types the contract
|
|
77
|
+
* allows for a transfer leg (`verified_blockchain`, `wire`, and `ach` are
|
|
78
|
+
* `Transaction`-only). A transfer that ever carries one of those, or a location
|
|
79
|
+
* kind not yet invented, degrades to `unrecognized` with the raw `type` string
|
|
80
|
+
* rather than failing the whole read — the same forward-compatibility contract as
|
|
81
|
+
* every other closed set here.
|
|
82
|
+
*/
|
|
83
|
+
export type TransferSourceLocation = {
|
|
84
|
+
readonly kind: 'account';
|
|
85
|
+
/** The account id. Named `accountId` here (the wire spells it `id`) so it
|
|
86
|
+
* is not confused with the transfer's own `id` at `transfer.source.id`. */
|
|
87
|
+
readonly accountId: string;
|
|
88
|
+
} | {
|
|
89
|
+
readonly kind: 'blockchain';
|
|
90
|
+
/**
|
|
91
|
+
* Chain of the on-chain leg, as a plain string rather than a closed set —
|
|
92
|
+
* same reasoning as `Account.blockchain`: new chains ship without an SDK
|
|
93
|
+
* release, and the service's own chain type is the thing that would have
|
|
94
|
+
* to grow, not this union.
|
|
95
|
+
*
|
|
96
|
+
* **Nullable**, despite the OpenAPI schema marking
|
|
97
|
+
* `TransferSourceBlockchainLocation.chain` required: the service builds a
|
|
98
|
+
* blockchain source leg with no chain when the leg was recorded before its
|
|
99
|
+
* blockchain metadata backfilled, and the schema does not prevent it from
|
|
100
|
+
* sending that leg anyway.
|
|
101
|
+
*/
|
|
102
|
+
readonly chain: string | null;
|
|
103
|
+
} | {
|
|
104
|
+
readonly kind: 'unrecognized';
|
|
105
|
+
readonly rawValue: string | null;
|
|
106
|
+
};
|
|
107
|
+
/** The redacted shape `JSON.stringify`/`toString` produce for a destination account leg. */
|
|
108
|
+
export type TransferDestinationAccountLocationRendering = {
|
|
109
|
+
readonly kind: 'account';
|
|
110
|
+
readonly accountId: string;
|
|
111
|
+
readonly address: string | null;
|
|
112
|
+
readonly addressTag: string | null;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* A transfer destination that is a DAA account (OpenAPI
|
|
116
|
+
* `TransferDestinationAccountLocation`).
|
|
117
|
+
*
|
|
118
|
+
* Unlike the source shape, a destination account leg can carry the on-chain
|
|
119
|
+
* `address`/`addressTag` funds arrived at — present only when this account leg
|
|
120
|
+
* received a crypto deposit. A crypto address is treated as sensitive data, so
|
|
121
|
+
* it is held the same way `Money` holds `amount`: behind a `#` private field
|
|
122
|
+
* and a prototype accessor, with `toJSON`/`toString` reporting only *whether*
|
|
123
|
+
* one is present. The service redacts it from its own logs but still sends it
|
|
124
|
+
* in the JSON body; this SDK redacts the JSON rendering too.
|
|
125
|
+
*/
|
|
126
|
+
export declare class TransferDestinationAccountLocation {
|
|
127
|
+
#private;
|
|
128
|
+
readonly kind: "account";
|
|
129
|
+
readonly accountId: string;
|
|
130
|
+
/** @internal Constructed only by the SDK's response decoder. */
|
|
131
|
+
constructor(fields: {
|
|
132
|
+
accountId: string;
|
|
133
|
+
address: string | null;
|
|
134
|
+
addressTag: string | null;
|
|
135
|
+
});
|
|
136
|
+
/** The on-chain address this account leg received a deposit at, or `null` if it did not. */
|
|
137
|
+
get address(): string | null;
|
|
138
|
+
/** Secondary on-chain identifier (e.g. a Stellar memo) paired with {@link address}; nullable. */
|
|
139
|
+
get addressTag(): string | null;
|
|
140
|
+
toJSON(): TransferDestinationAccountLocationRendering;
|
|
141
|
+
toString(): string;
|
|
142
|
+
}
|
|
143
|
+
/** The redacted shape `JSON.stringify`/`toString` produce for a destination blockchain leg. */
|
|
144
|
+
export type TransferDestinationBlockchainLocationRendering = {
|
|
145
|
+
readonly kind: 'blockchain';
|
|
146
|
+
readonly chain: string | null;
|
|
147
|
+
readonly address: string | null;
|
|
148
|
+
readonly addressTag: string | null;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* A transfer destination that is an on-chain address (OpenAPI
|
|
152
|
+
* `TransferDestinationBlockchainLocation`).
|
|
153
|
+
*
|
|
154
|
+
* **Both `chain` and `address` are nullable here, despite the OpenAPI schema
|
|
155
|
+
* marking both required.** The wire's `type: "blockchain"` comes from two
|
|
156
|
+
* different kinds of leg that this SDK cannot tell apart from the JSON alone:
|
|
157
|
+
* a verified-blockchain leg folds into it, because the public transfer
|
|
158
|
+
* taxonomy has no verified form on a read.
|
|
159
|
+
*
|
|
160
|
+
* - A plain blockchain leg always resolves `address` (the service falls back
|
|
161
|
+
* to the stored leg id when metadata is absent), so that path alone would
|
|
162
|
+
* justify treating it as required.
|
|
163
|
+
* - A folded verified-blockchain leg does **not** fall back — one with no
|
|
164
|
+
* recorded metadata yet genuinely has no address to report.
|
|
165
|
+
* - Both kinds report `chain` only once their blockchain metadata is
|
|
166
|
+
* recorded.
|
|
167
|
+
*
|
|
168
|
+
* Since either path can produce the wire shape this SDK decodes, and one of
|
|
169
|
+
* them can leave `address` absent, `address` has to be modeled as optional —
|
|
170
|
+
* requiring it would reject a real, un-backfilled verified-blockchain
|
|
171
|
+
* destination. Both fields are redacted the same way `Money.amount` is: behind
|
|
172
|
+
* a `#` private field, never an own enumerable property; `chain` is public
|
|
173
|
+
* because it is not sensitive.
|
|
174
|
+
*/
|
|
175
|
+
export declare class TransferDestinationBlockchainLocation {
|
|
176
|
+
#private;
|
|
177
|
+
readonly kind: "blockchain";
|
|
178
|
+
readonly chain: string | null;
|
|
179
|
+
/** @internal Constructed only by the SDK's response decoder. */
|
|
180
|
+
constructor(fields: {
|
|
181
|
+
chain: string | null;
|
|
182
|
+
address: string | null;
|
|
183
|
+
addressTag: string | null;
|
|
184
|
+
});
|
|
185
|
+
/** The destination on-chain address, or `null` for an un-backfilled verified-blockchain leg. See the class note. */
|
|
186
|
+
get address(): string | null;
|
|
187
|
+
/** Secondary on-chain identifier (e.g. a Stellar memo) paired with {@link address}; nullable. */
|
|
188
|
+
get addressTag(): string | null;
|
|
189
|
+
toJSON(): TransferDestinationBlockchainLocationRendering;
|
|
190
|
+
toString(): string;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* A transfer's destination leg (OpenAPI `TransferDestinationLocation`, a `oneOf`
|
|
194
|
+
* of `TransferDestinationBlockchainLocation` and `TransferDestinationAccountLocation`).
|
|
195
|
+
*
|
|
196
|
+
* See {@link TransferSourceLocation} for the shared discriminator and the
|
|
197
|
+
* forward-compatibility contract for a `type` this SDK does not recognise.
|
|
198
|
+
*/
|
|
199
|
+
export type TransferDestinationLocation = TransferDestinationAccountLocation | TransferDestinationBlockchainLocation | {
|
|
200
|
+
readonly kind: 'unrecognized';
|
|
201
|
+
readonly rawValue: string | null;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* A single fee applied to a transfer (OpenAPI `Fee`).
|
|
205
|
+
*
|
|
206
|
+
* `amount` reuses `Money` rather than carrying its own decimal string — the exact
|
|
207
|
+
* problem `Money` already solves (the service serializes `Fee.amount` the same
|
|
208
|
+
* way, as a plain decimal string) and redacts the same way. `type` is a plain
|
|
209
|
+
* `string`: the service does not constrain it to an enum (the schema's
|
|
210
|
+
* `network` value is documentation only, not a runtime constraint), so there is
|
|
211
|
+
* no closed set to model or to get wrong.
|
|
212
|
+
*/
|
|
213
|
+
export type Fee = {
|
|
214
|
+
readonly amount: Money;
|
|
215
|
+
readonly type: string;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Policy-engine evaluation attached to a transfer when one is available (OpenAPI
|
|
219
|
+
* `PolicyEvaluation`).
|
|
220
|
+
*
|
|
221
|
+
* `status` is a plain `string`, matching the service: `PolicyEvaluation.status`
|
|
222
|
+
* is a free-form string, not an enum, so — unlike `TransferStatus`/
|
|
223
|
+
* `TransferErrorCode` — there is no closed set to widen or to fall back from.
|
|
224
|
+
*/
|
|
225
|
+
export type TransferPolicyEvaluation = {
|
|
226
|
+
readonly status: string;
|
|
227
|
+
};
|
|
228
|
+
/** The redacted shape `JSON.stringify(transfer)` produces. */
|
|
229
|
+
export type TransferRendering = {
|
|
230
|
+
readonly id: string;
|
|
231
|
+
readonly source: TransferSourceLocation | null;
|
|
232
|
+
readonly destination: TransferDestinationLocation | null;
|
|
233
|
+
readonly amount: {
|
|
234
|
+
readonly amount: string;
|
|
235
|
+
readonly currency: string;
|
|
236
|
+
};
|
|
237
|
+
readonly fees: string;
|
|
238
|
+
readonly transactionHash: string | null;
|
|
239
|
+
readonly destinationTransactionHash: string | null;
|
|
240
|
+
readonly status: TransferStatus;
|
|
241
|
+
readonly errorCode: TransferErrorCode | null;
|
|
242
|
+
readonly policyEvaluation: TransferPolicyEvaluation | null;
|
|
243
|
+
readonly createDate: string | null;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* A DAA transfer, as the service reports it (OpenAPI `Transfer`, the response
|
|
247
|
+
* contract for `POST /v1/accounts/transfers`, each element of
|
|
248
|
+
* `GET /v1/accounts/transfers`, and `GET /v1/accounts/transfers/{transferId}`).
|
|
249
|
+
*
|
|
250
|
+
* Read-only at runtime as well as in the type system, for the same reason as
|
|
251
|
+
* `Account`: `readonly` is erased at compile time and would leave a returned
|
|
252
|
+
* transfer mutable through a cast. The instance is frozen and the fee list is a
|
|
253
|
+
* frozen array.
|
|
254
|
+
*
|
|
255
|
+
* **Not constructible by a consumer.** Exported from `index.ts` as a type only,
|
|
256
|
+
* and the `#` private fields make the type nominal so an object literal cannot
|
|
257
|
+
* be typed as a `Transfer`.
|
|
258
|
+
*
|
|
259
|
+
* **Only `id`, `amount`, and `status` are guaranteed non-null here — `source`
|
|
260
|
+
* and `destination` are not, despite the OpenAPI schema marking all five
|
|
261
|
+
* required.** That marking is a hint, not proof; the only evidence that
|
|
262
|
+
* settles requiredness is whether a service code path can produce the value
|
|
263
|
+
* absent, and for `source`/`destination` one does: the service reports no leg
|
|
264
|
+
* at all for a fiat source or destination, and no source leg for a
|
|
265
|
+
* verified-blockchain source. A transfer with a fiat leg — an ordinary onramp
|
|
266
|
+
* or offramp — is real, and the service omits null locations, so that leg is
|
|
267
|
+
* simply **absent** from the JSON body, not `null`; requiring it would reject
|
|
268
|
+
* an otherwise-readable transfer. `fees`, `transactionHash`,
|
|
269
|
+
* `destinationTransactionHash`, `errorCode`, and `policyEvaluation` are each
|
|
270
|
+
* documented as present only in some cases (a non-zero fee exists; a leg is
|
|
271
|
+
* blockchain; the CCTP destination leg has minted; status is `failed`; one is
|
|
272
|
+
* available) and decode to empty/`null` when absent, exactly as documented.
|
|
273
|
+
*
|
|
274
|
+
* **`createDate` is treated as optional despite looking mandatory**, and that is
|
|
275
|
+
* a deliberate hedge rather than an oversight: the OpenAPI schema does not mark
|
|
276
|
+
* it required at all (unlike `id`/`amount`/`status`) — the same kind of gap
|
|
277
|
+
* as `Account.description`, which the service can omit. This SDK reports it
|
|
278
|
+
* as it finds it rather than rejecting a transfer that is otherwise perfectly
|
|
279
|
+
* readable.
|
|
280
|
+
*
|
|
281
|
+
* **`amount` and `fees` do not appear in any default rendering.** Like `Account`'s
|
|
282
|
+
* `balances`, they sit behind prototype accessors rather than own properties, so
|
|
283
|
+
* `Object.keys`, `JSON.stringify`, `{ ...transfer }`, `for...in`, and the object
|
|
284
|
+
* inspectors behind `console.log` do not reach them; `toJSON`/`toString` reduce
|
|
285
|
+
* `fees` to a count and delegate `amount` to `Money`'s own redacted rendering.
|
|
286
|
+
* `source`/`destination` are plain own properties — safe, because a location that
|
|
287
|
+
* can carry an address redacts it itself (see
|
|
288
|
+
* {@link TransferDestinationAccountLocation}/{@link TransferDestinationBlockchainLocation}).
|
|
289
|
+
*/
|
|
290
|
+
export declare class Transfer {
|
|
291
|
+
#private;
|
|
292
|
+
/** Transfer id. */
|
|
293
|
+
readonly id: string;
|
|
294
|
+
/** `null` for a fiat leg (an onramp) or a stray `verified_blockchain` source — see the class note. */
|
|
295
|
+
readonly source: TransferSourceLocation | null;
|
|
296
|
+
/** `null` for a fiat leg (an offramp) — see the class note. */
|
|
297
|
+
readonly destination: TransferDestinationLocation | null;
|
|
298
|
+
readonly status: TransferStatus;
|
|
299
|
+
/** Present only when {@link status} is `failed`. */
|
|
300
|
+
readonly errorCode: TransferErrorCode | null;
|
|
301
|
+
/** On-chain transaction hash; present only when a leg is blockchain. */
|
|
302
|
+
readonly transactionHash: string | null;
|
|
303
|
+
/**
|
|
304
|
+
* CCTP destination-mint hash — the transaction hash of the destination leg
|
|
305
|
+
* minting on the receiving chain. Present only for a CCTP transfer once
|
|
306
|
+
* that leg has minted; `null` otherwise.
|
|
307
|
+
*/
|
|
308
|
+
readonly destinationTransactionHash: string | null;
|
|
309
|
+
/** Policy-evaluation; absent until one is available. */
|
|
310
|
+
readonly policyEvaluation: TransferPolicyEvaluation | null;
|
|
311
|
+
/** Creation timestamp, exactly as the service sent it (ISO-8601 UTC). See the class note on why this is optional. */
|
|
312
|
+
readonly createDate: string | null;
|
|
313
|
+
/** @internal Constructed only by the SDK's response decoder. */
|
|
314
|
+
constructor(fields: {
|
|
315
|
+
readonly id: string;
|
|
316
|
+
readonly source: TransferSourceLocation | null;
|
|
317
|
+
readonly destination: TransferDestinationLocation | null;
|
|
318
|
+
readonly amount: Money;
|
|
319
|
+
readonly fees: readonly Fee[];
|
|
320
|
+
readonly transactionHash: string | null;
|
|
321
|
+
readonly destinationTransactionHash: string | null;
|
|
322
|
+
readonly status: TransferStatus;
|
|
323
|
+
readonly errorCode: TransferErrorCode | null;
|
|
324
|
+
readonly policyEvaluation: TransferPolicyEvaluation | null;
|
|
325
|
+
readonly createDate: string | null;
|
|
326
|
+
});
|
|
327
|
+
/** The transferred amount. Reuses `Money`, which redacts its own `amount` field. */
|
|
328
|
+
get amount(): Money;
|
|
329
|
+
/** Applied fees. Empty when the service sent none (no non-zero fee exists). */
|
|
330
|
+
get fees(): readonly Fee[];
|
|
331
|
+
/** Identifiers and states render; the amount and fee amounts do not. */
|
|
332
|
+
toJSON(): TransferRendering;
|
|
333
|
+
/** Identifiers and states print; the amount and fee amounts do not. */
|
|
334
|
+
toString(): string;
|
|
335
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
20
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
21
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
22
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
23
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
24
|
+
};
|
|
25
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
26
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
27
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
28
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
29
|
+
};
|
|
30
|
+
var _TransferDestinationAccountLocation_address, _TransferDestinationAccountLocation_addressTag, _TransferDestinationBlockchainLocation_address, _TransferDestinationBlockchainLocation_addressTag, _Transfer_amount, _Transfer_fees;
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.Transfer = exports.TransferDestinationBlockchainLocation = exports.TransferDestinationAccountLocation = void 0;
|
|
33
|
+
const redaction_1 = require("./redaction");
|
|
34
|
+
/**
|
|
35
|
+
* A transfer destination that is a DAA account (OpenAPI
|
|
36
|
+
* `TransferDestinationAccountLocation`).
|
|
37
|
+
*
|
|
38
|
+
* Unlike the source shape, a destination account leg can carry the on-chain
|
|
39
|
+
* `address`/`addressTag` funds arrived at — present only when this account leg
|
|
40
|
+
* received a crypto deposit. A crypto address is treated as sensitive data, so
|
|
41
|
+
* it is held the same way `Money` holds `amount`: behind a `#` private field
|
|
42
|
+
* and a prototype accessor, with `toJSON`/`toString` reporting only *whether*
|
|
43
|
+
* one is present. The service redacts it from its own logs but still sends it
|
|
44
|
+
* in the JSON body; this SDK redacts the JSON rendering too.
|
|
45
|
+
*/
|
|
46
|
+
class TransferDestinationAccountLocation {
|
|
47
|
+
/** @internal Constructed only by the SDK's response decoder. */
|
|
48
|
+
constructor(fields) {
|
|
49
|
+
this.kind = 'account';
|
|
50
|
+
_TransferDestinationAccountLocation_address.set(this, void 0);
|
|
51
|
+
_TransferDestinationAccountLocation_addressTag.set(this, void 0);
|
|
52
|
+
this.accountId = fields.accountId;
|
|
53
|
+
__classPrivateFieldSet(this, _TransferDestinationAccountLocation_address, fields.address, "f");
|
|
54
|
+
__classPrivateFieldSet(this, _TransferDestinationAccountLocation_addressTag, fields.addressTag, "f");
|
|
55
|
+
Object.freeze(this);
|
|
56
|
+
}
|
|
57
|
+
/** The on-chain address this account leg received a deposit at, or `null` if it did not. */
|
|
58
|
+
get address() {
|
|
59
|
+
return __classPrivateFieldGet(this, _TransferDestinationAccountLocation_address, "f");
|
|
60
|
+
}
|
|
61
|
+
/** Secondary on-chain identifier (e.g. a Stellar memo) paired with {@link address}; nullable. */
|
|
62
|
+
get addressTag() {
|
|
63
|
+
return __classPrivateFieldGet(this, _TransferDestinationAccountLocation_addressTag, "f");
|
|
64
|
+
}
|
|
65
|
+
toJSON() {
|
|
66
|
+
return {
|
|
67
|
+
kind: this.kind,
|
|
68
|
+
accountId: this.accountId,
|
|
69
|
+
address: __classPrivateFieldGet(this, _TransferDestinationAccountLocation_address, "f") === null ? null : redaction_1.REDACTED,
|
|
70
|
+
addressTag: __classPrivateFieldGet(this, _TransferDestinationAccountLocation_addressTag, "f") === null ? null : redaction_1.REDACTED,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
toString() {
|
|
74
|
+
return (`TransferDestinationAccountLocation(kind=account, accountId=${this.accountId}, ` +
|
|
75
|
+
`address=${__classPrivateFieldGet(this, _TransferDestinationAccountLocation_address, "f") === null ? 'null' : redaction_1.REDACTED}, ` +
|
|
76
|
+
`addressTag=${__classPrivateFieldGet(this, _TransferDestinationAccountLocation_addressTag, "f") === null ? 'null' : redaction_1.REDACTED})`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.TransferDestinationAccountLocation = TransferDestinationAccountLocation;
|
|
80
|
+
_TransferDestinationAccountLocation_address = new WeakMap(), _TransferDestinationAccountLocation_addressTag = new WeakMap();
|
|
81
|
+
/**
|
|
82
|
+
* A transfer destination that is an on-chain address (OpenAPI
|
|
83
|
+
* `TransferDestinationBlockchainLocation`).
|
|
84
|
+
*
|
|
85
|
+
* **Both `chain` and `address` are nullable here, despite the OpenAPI schema
|
|
86
|
+
* marking both required.** The wire's `type: "blockchain"` comes from two
|
|
87
|
+
* different kinds of leg that this SDK cannot tell apart from the JSON alone:
|
|
88
|
+
* a verified-blockchain leg folds into it, because the public transfer
|
|
89
|
+
* taxonomy has no verified form on a read.
|
|
90
|
+
*
|
|
91
|
+
* - A plain blockchain leg always resolves `address` (the service falls back
|
|
92
|
+
* to the stored leg id when metadata is absent), so that path alone would
|
|
93
|
+
* justify treating it as required.
|
|
94
|
+
* - A folded verified-blockchain leg does **not** fall back — one with no
|
|
95
|
+
* recorded metadata yet genuinely has no address to report.
|
|
96
|
+
* - Both kinds report `chain` only once their blockchain metadata is
|
|
97
|
+
* recorded.
|
|
98
|
+
*
|
|
99
|
+
* Since either path can produce the wire shape this SDK decodes, and one of
|
|
100
|
+
* them can leave `address` absent, `address` has to be modeled as optional —
|
|
101
|
+
* requiring it would reject a real, un-backfilled verified-blockchain
|
|
102
|
+
* destination. Both fields are redacted the same way `Money.amount` is: behind
|
|
103
|
+
* a `#` private field, never an own enumerable property; `chain` is public
|
|
104
|
+
* because it is not sensitive.
|
|
105
|
+
*/
|
|
106
|
+
class TransferDestinationBlockchainLocation {
|
|
107
|
+
/** @internal Constructed only by the SDK's response decoder. */
|
|
108
|
+
constructor(fields) {
|
|
109
|
+
this.kind = 'blockchain';
|
|
110
|
+
_TransferDestinationBlockchainLocation_address.set(this, void 0);
|
|
111
|
+
_TransferDestinationBlockchainLocation_addressTag.set(this, void 0);
|
|
112
|
+
this.chain = fields.chain;
|
|
113
|
+
__classPrivateFieldSet(this, _TransferDestinationBlockchainLocation_address, fields.address, "f");
|
|
114
|
+
__classPrivateFieldSet(this, _TransferDestinationBlockchainLocation_addressTag, fields.addressTag, "f");
|
|
115
|
+
Object.freeze(this);
|
|
116
|
+
}
|
|
117
|
+
/** The destination on-chain address, or `null` for an un-backfilled verified-blockchain leg. See the class note. */
|
|
118
|
+
get address() {
|
|
119
|
+
return __classPrivateFieldGet(this, _TransferDestinationBlockchainLocation_address, "f");
|
|
120
|
+
}
|
|
121
|
+
/** Secondary on-chain identifier (e.g. a Stellar memo) paired with {@link address}; nullable. */
|
|
122
|
+
get addressTag() {
|
|
123
|
+
return __classPrivateFieldGet(this, _TransferDestinationBlockchainLocation_addressTag, "f");
|
|
124
|
+
}
|
|
125
|
+
toJSON() {
|
|
126
|
+
return {
|
|
127
|
+
kind: this.kind,
|
|
128
|
+
chain: this.chain,
|
|
129
|
+
address: __classPrivateFieldGet(this, _TransferDestinationBlockchainLocation_address, "f") === null ? null : redaction_1.REDACTED,
|
|
130
|
+
addressTag: __classPrivateFieldGet(this, _TransferDestinationBlockchainLocation_addressTag, "f") === null ? null : redaction_1.REDACTED,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
toString() {
|
|
134
|
+
return (`TransferDestinationBlockchainLocation(kind=blockchain, chain=${this.chain}, ` +
|
|
135
|
+
`address=${__classPrivateFieldGet(this, _TransferDestinationBlockchainLocation_address, "f") === null ? 'null' : redaction_1.REDACTED}, ` +
|
|
136
|
+
`addressTag=${__classPrivateFieldGet(this, _TransferDestinationBlockchainLocation_addressTag, "f") === null ? 'null' : redaction_1.REDACTED})`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.TransferDestinationBlockchainLocation = TransferDestinationBlockchainLocation;
|
|
140
|
+
_TransferDestinationBlockchainLocation_address = new WeakMap(), _TransferDestinationBlockchainLocation_addressTag = new WeakMap();
|
|
141
|
+
/**
|
|
142
|
+
* A DAA transfer, as the service reports it (OpenAPI `Transfer`, the response
|
|
143
|
+
* contract for `POST /v1/accounts/transfers`, each element of
|
|
144
|
+
* `GET /v1/accounts/transfers`, and `GET /v1/accounts/transfers/{transferId}`).
|
|
145
|
+
*
|
|
146
|
+
* Read-only at runtime as well as in the type system, for the same reason as
|
|
147
|
+
* `Account`: `readonly` is erased at compile time and would leave a returned
|
|
148
|
+
* transfer mutable through a cast. The instance is frozen and the fee list is a
|
|
149
|
+
* frozen array.
|
|
150
|
+
*
|
|
151
|
+
* **Not constructible by a consumer.** Exported from `index.ts` as a type only,
|
|
152
|
+
* and the `#` private fields make the type nominal so an object literal cannot
|
|
153
|
+
* be typed as a `Transfer`.
|
|
154
|
+
*
|
|
155
|
+
* **Only `id`, `amount`, and `status` are guaranteed non-null here — `source`
|
|
156
|
+
* and `destination` are not, despite the OpenAPI schema marking all five
|
|
157
|
+
* required.** That marking is a hint, not proof; the only evidence that
|
|
158
|
+
* settles requiredness is whether a service code path can produce the value
|
|
159
|
+
* absent, and for `source`/`destination` one does: the service reports no leg
|
|
160
|
+
* at all for a fiat source or destination, and no source leg for a
|
|
161
|
+
* verified-blockchain source. A transfer with a fiat leg — an ordinary onramp
|
|
162
|
+
* or offramp — is real, and the service omits null locations, so that leg is
|
|
163
|
+
* simply **absent** from the JSON body, not `null`; requiring it would reject
|
|
164
|
+
* an otherwise-readable transfer. `fees`, `transactionHash`,
|
|
165
|
+
* `destinationTransactionHash`, `errorCode`, and `policyEvaluation` are each
|
|
166
|
+
* documented as present only in some cases (a non-zero fee exists; a leg is
|
|
167
|
+
* blockchain; the CCTP destination leg has minted; status is `failed`; one is
|
|
168
|
+
* available) and decode to empty/`null` when absent, exactly as documented.
|
|
169
|
+
*
|
|
170
|
+
* **`createDate` is treated as optional despite looking mandatory**, and that is
|
|
171
|
+
* a deliberate hedge rather than an oversight: the OpenAPI schema does not mark
|
|
172
|
+
* it required at all (unlike `id`/`amount`/`status`) — the same kind of gap
|
|
173
|
+
* as `Account.description`, which the service can omit. This SDK reports it
|
|
174
|
+
* as it finds it rather than rejecting a transfer that is otherwise perfectly
|
|
175
|
+
* readable.
|
|
176
|
+
*
|
|
177
|
+
* **`amount` and `fees` do not appear in any default rendering.** Like `Account`'s
|
|
178
|
+
* `balances`, they sit behind prototype accessors rather than own properties, so
|
|
179
|
+
* `Object.keys`, `JSON.stringify`, `{ ...transfer }`, `for...in`, and the object
|
|
180
|
+
* inspectors behind `console.log` do not reach them; `toJSON`/`toString` reduce
|
|
181
|
+
* `fees` to a count and delegate `amount` to `Money`'s own redacted rendering.
|
|
182
|
+
* `source`/`destination` are plain own properties — safe, because a location that
|
|
183
|
+
* can carry an address redacts it itself (see
|
|
184
|
+
* {@link TransferDestinationAccountLocation}/{@link TransferDestinationBlockchainLocation}).
|
|
185
|
+
*/
|
|
186
|
+
class Transfer {
|
|
187
|
+
/** @internal Constructed only by the SDK's response decoder. */
|
|
188
|
+
constructor(fields) {
|
|
189
|
+
_Transfer_amount.set(this, void 0);
|
|
190
|
+
_Transfer_fees.set(this, void 0);
|
|
191
|
+
this.id = fields.id;
|
|
192
|
+
this.source = fields.source;
|
|
193
|
+
this.destination = fields.destination;
|
|
194
|
+
this.status = fields.status;
|
|
195
|
+
this.errorCode = fields.errorCode;
|
|
196
|
+
this.transactionHash = fields.transactionHash;
|
|
197
|
+
this.destinationTransactionHash = fields.destinationTransactionHash;
|
|
198
|
+
this.policyEvaluation = fields.policyEvaluation;
|
|
199
|
+
this.createDate = fields.createDate;
|
|
200
|
+
__classPrivateFieldSet(this, _Transfer_amount, fields.amount, "f");
|
|
201
|
+
// Same reasoning as `Account#balances`: freezing a copy rather than the
|
|
202
|
+
// caller's own array, so this construction cannot reach back and freeze an
|
|
203
|
+
// argument the caller still holds a reference to.
|
|
204
|
+
__classPrivateFieldSet(this, _Transfer_fees, Object.freeze(fields.fees.slice()), "f");
|
|
205
|
+
Object.freeze(this);
|
|
206
|
+
}
|
|
207
|
+
/** The transferred amount. Reuses `Money`, which redacts its own `amount` field. */
|
|
208
|
+
get amount() {
|
|
209
|
+
return __classPrivateFieldGet(this, _Transfer_amount, "f");
|
|
210
|
+
}
|
|
211
|
+
/** Applied fees. Empty when the service sent none (no non-zero fee exists). */
|
|
212
|
+
get fees() {
|
|
213
|
+
return __classPrivateFieldGet(this, _Transfer_fees, "f");
|
|
214
|
+
}
|
|
215
|
+
/** Identifiers and states render; the amount and fee amounts do not. */
|
|
216
|
+
toJSON() {
|
|
217
|
+
return {
|
|
218
|
+
id: this.id,
|
|
219
|
+
source: this.source,
|
|
220
|
+
destination: this.destination,
|
|
221
|
+
amount: __classPrivateFieldGet(this, _Transfer_amount, "f").toJSON(),
|
|
222
|
+
fees: `${__classPrivateFieldGet(this, _Transfer_fees, "f").length} entries`,
|
|
223
|
+
transactionHash: this.transactionHash,
|
|
224
|
+
destinationTransactionHash: this.destinationTransactionHash,
|
|
225
|
+
status: this.status,
|
|
226
|
+
errorCode: this.errorCode,
|
|
227
|
+
policyEvaluation: this.policyEvaluation,
|
|
228
|
+
createDate: this.createDate,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/** Identifiers and states print; the amount and fee amounts do not. */
|
|
232
|
+
toString() {
|
|
233
|
+
return (`Transfer(id=${this.id}, status=${this.status.kind}, ` +
|
|
234
|
+
`errorCode=${this.errorCode === null ? 'null' : this.errorCode.kind}, ` +
|
|
235
|
+
`amount=${__classPrivateFieldGet(this, _Transfer_amount, "f").toString()}, fees=${__classPrivateFieldGet(this, _Transfer_fees, "f").length} entries, ` +
|
|
236
|
+
`transactionHash=${this.transactionHash}, createDate=${this.createDate})`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
exports.Transfer = Transfer;
|
|
240
|
+
_Transfer_amount = new WeakMap(), _Transfer_fees = new WeakMap();
|