@turnkey/react-wallet-kit 1.9.0 → 1.11.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/dist/components/auth/OTP.mjs +1 -1
- package/dist/components/design/Lottie/Wrapper.mjs +1 -1
- package/dist/providers/client/Provider.d.ts.map +1 -1
- package/dist/providers/client/Provider.js +59 -2
- package/dist/providers/client/Provider.js.map +1 -1
- package/dist/providers/client/Provider.mjs +983 -870
- package/dist/providers/client/Provider.mjs.map +1 -1
- package/dist/providers/client/Types.d.ts +20 -1
- package/dist/providers/client/Types.d.ts.map +1 -1
- package/dist/providers/client/Types.js.map +1 -1
- package/dist/providers/client/Types.mjs.map +1 -1
- package/dist/providers/modal/Provider.mjs +1 -1
- package/dist/typedoc-entry/index.d.ts +1 -0
- package/dist/typedoc-entry/index.d.ts.map +1 -1
- package/dist/types/method-types.d.ts +8 -1
- package/dist/types/method-types.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray,
|
|
1
|
+
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.mjs';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useState, useRef } from 'react';
|
|
4
4
|
import { useModal } from '../../providers/modal/Hook.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray,
|
|
1
|
+
import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../../../_virtual/_rollupPluginBabelHelpers.mjs';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useState, useEffect } from 'react';
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/providers/client/Provider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/providers/client/Provider.tsx"],"names":[],"mappings":"AAwHA,OAAO,EAAE,SAAS,EAA4C,MAAM,OAAO,CAAC;AAwB5E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAM3B,MAAM,kBAAkB,CAAC;AAwD1B;;GAEG;AACH,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,SAAS,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA2oLxD,CAAC"}
|
|
@@ -1484,6 +1484,10 @@ const ClientProvider = ({
|
|
|
1484
1484
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1485
1485
|
return utils.withTurnkeyErrorHandling(() => client.ethSendTransaction(params), () => logout(), callbacks, "Failed to send eth transaction");
|
|
1486
1486
|
}, [client, callbacks, logout]);
|
|
1487
|
+
const ethSendErc20Transfer = react.useCallback(async params => {
|
|
1488
|
+
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1489
|
+
return utils.withTurnkeyErrorHandling(() => client.ethSendErc20Transfer(params), () => logout(), callbacks, "Failed to send ERC20 transfer");
|
|
1490
|
+
}, [client, callbacks, logout]);
|
|
1487
1491
|
const solSendTransaction = react.useCallback(async params => {
|
|
1488
1492
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1489
1493
|
return utils.withTurnkeyErrorHandling(() => client.solSendTransaction(params), () => logout(), callbacks, "Failed to send sol transaction");
|
|
@@ -3412,7 +3416,8 @@ const ClientProvider = ({
|
|
|
3412
3416
|
organizationId,
|
|
3413
3417
|
sendTransactionStatusId
|
|
3414
3418
|
});
|
|
3415
|
-
const
|
|
3419
|
+
const txDetails = pollResult;
|
|
3420
|
+
const txHash = txDetails.eth?.txHash ?? txDetails.solana?.signature ?? txDetails.txHash;
|
|
3416
3421
|
return txHash ? {
|
|
3417
3422
|
txHash
|
|
3418
3423
|
} : {};
|
|
@@ -3433,6 +3438,56 @@ const ClientProvider = ({
|
|
|
3433
3438
|
});
|
|
3434
3439
|
});
|
|
3435
3440
|
}, [ethSendTransaction, getSession, pollTransactionStatus, pushPage, solSendTransaction]);
|
|
3441
|
+
const handleSendErc20Transfer = react.useCallback(async params => {
|
|
3442
|
+
const session = await getSession();
|
|
3443
|
+
const organizationId = params.organizationId || session?.organizationId;
|
|
3444
|
+
if (!organizationId) {
|
|
3445
|
+
throw new sdkTypes.TurnkeyError("A session or passed in organization ID is required.", sdkTypes.TurnkeyErrorCodes.INVALID_REQUEST);
|
|
3446
|
+
}
|
|
3447
|
+
const {
|
|
3448
|
+
transfer,
|
|
3449
|
+
icon,
|
|
3450
|
+
stampWith,
|
|
3451
|
+
successPageDuration = 2000
|
|
3452
|
+
} = params;
|
|
3453
|
+
const {
|
|
3454
|
+
caip2
|
|
3455
|
+
} = transfer;
|
|
3456
|
+
return new Promise((resolve, reject) => {
|
|
3457
|
+
const action = async () => {
|
|
3458
|
+
const sendTransactionStatusId = await ethSendErc20Transfer({
|
|
3459
|
+
organizationId,
|
|
3460
|
+
transfer,
|
|
3461
|
+
stampWith
|
|
3462
|
+
});
|
|
3463
|
+
if (!sendTransactionStatusId) {
|
|
3464
|
+
throw new sdkTypes.TurnkeyError("Missing sendTransactionStatusId", sdkTypes.TurnkeyErrorCodes.BAD_RESPONSE);
|
|
3465
|
+
}
|
|
3466
|
+
const pollResult = await pollTransactionStatus({
|
|
3467
|
+
organizationId,
|
|
3468
|
+
sendTransactionStatusId
|
|
3469
|
+
});
|
|
3470
|
+
const txHash = pollResult?.eth?.txHash ?? pollResult?.txHash;
|
|
3471
|
+
return txHash ? {
|
|
3472
|
+
txHash
|
|
3473
|
+
} : {};
|
|
3474
|
+
};
|
|
3475
|
+
pushPage({
|
|
3476
|
+
key: "Send ERC20 Transfer",
|
|
3477
|
+
showTitle: false,
|
|
3478
|
+
preventBack: true,
|
|
3479
|
+
onClose: () => reject(new sdkTypes.TurnkeyError("User canceled the transaction.", sdkTypes.TurnkeyErrorCodes.USER_CANCELED)),
|
|
3480
|
+
content: jsxRuntime.jsx(SendTransaction.SendTransactionPage, {
|
|
3481
|
+
icon: icon ?? helpers.getChainLogo(caip2),
|
|
3482
|
+
action: action,
|
|
3483
|
+
caip2: caip2,
|
|
3484
|
+
successPageDuration: successPageDuration,
|
|
3485
|
+
onSuccess: () => resolve(),
|
|
3486
|
+
onError: err => reject(err)
|
|
3487
|
+
})
|
|
3488
|
+
});
|
|
3489
|
+
});
|
|
3490
|
+
}, [ethSendErc20Transfer, getSession, pollTransactionStatus, pushPage]);
|
|
3436
3491
|
const handleOnRamp = react.useCallback(async params => {
|
|
3437
3492
|
const {
|
|
3438
3493
|
walletAccount,
|
|
@@ -3787,6 +3842,7 @@ const ClientProvider = ({
|
|
|
3787
3842
|
signMessage,
|
|
3788
3843
|
signTransaction,
|
|
3789
3844
|
ethSendTransaction,
|
|
3845
|
+
ethSendErc20Transfer,
|
|
3790
3846
|
solSendTransaction,
|
|
3791
3847
|
signAndSendTransaction,
|
|
3792
3848
|
pollTransactionStatus,
|
|
@@ -3850,7 +3906,8 @@ const ClientProvider = ({
|
|
|
3850
3906
|
handleRemoveUserPhoneNumber,
|
|
3851
3907
|
handleVerifyAppProofs,
|
|
3852
3908
|
handleOnRamp,
|
|
3853
|
-
handleSendTransaction
|
|
3909
|
+
handleSendTransaction,
|
|
3910
|
+
handleSendErc20Transfer
|
|
3854
3911
|
},
|
|
3855
3912
|
children: children
|
|
3856
3913
|
});
|