@turnkey/react-wallet-kit 1.9.0 → 1.10.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 +57 -1
- package/dist/providers/client/Provider.js.map +1 -1
- package/dist/providers/client/Provider.mjs +979 -867
- 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,CAqoLxD,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");
|
|
@@ -3433,6 +3437,56 @@ const ClientProvider = ({
|
|
|
3433
3437
|
});
|
|
3434
3438
|
});
|
|
3435
3439
|
}, [ethSendTransaction, getSession, pollTransactionStatus, pushPage, solSendTransaction]);
|
|
3440
|
+
const handleSendErc20Transfer = react.useCallback(async params => {
|
|
3441
|
+
const session = await getSession();
|
|
3442
|
+
const organizationId = params.organizationId || session?.organizationId;
|
|
3443
|
+
if (!organizationId) {
|
|
3444
|
+
throw new sdkTypes.TurnkeyError("A session or passed in organization ID is required.", sdkTypes.TurnkeyErrorCodes.INVALID_REQUEST);
|
|
3445
|
+
}
|
|
3446
|
+
const {
|
|
3447
|
+
transfer,
|
|
3448
|
+
icon,
|
|
3449
|
+
stampWith,
|
|
3450
|
+
successPageDuration = 2000
|
|
3451
|
+
} = params;
|
|
3452
|
+
const {
|
|
3453
|
+
caip2
|
|
3454
|
+
} = transfer;
|
|
3455
|
+
return new Promise((resolve, reject) => {
|
|
3456
|
+
const action = async () => {
|
|
3457
|
+
const sendTransactionStatusId = await ethSendErc20Transfer({
|
|
3458
|
+
organizationId,
|
|
3459
|
+
transfer,
|
|
3460
|
+
stampWith
|
|
3461
|
+
});
|
|
3462
|
+
if (!sendTransactionStatusId) {
|
|
3463
|
+
throw new sdkTypes.TurnkeyError("Missing sendTransactionStatusId", sdkTypes.TurnkeyErrorCodes.BAD_RESPONSE);
|
|
3464
|
+
}
|
|
3465
|
+
const pollResult = await pollTransactionStatus({
|
|
3466
|
+
organizationId,
|
|
3467
|
+
sendTransactionStatusId
|
|
3468
|
+
});
|
|
3469
|
+
const txHash = pollResult?.eth?.txHash ?? pollResult?.txHash;
|
|
3470
|
+
return txHash ? {
|
|
3471
|
+
txHash
|
|
3472
|
+
} : {};
|
|
3473
|
+
};
|
|
3474
|
+
pushPage({
|
|
3475
|
+
key: "Send ERC20 Transfer",
|
|
3476
|
+
showTitle: false,
|
|
3477
|
+
preventBack: true,
|
|
3478
|
+
onClose: () => reject(new sdkTypes.TurnkeyError("User canceled the transaction.", sdkTypes.TurnkeyErrorCodes.USER_CANCELED)),
|
|
3479
|
+
content: jsxRuntime.jsx(SendTransaction.SendTransactionPage, {
|
|
3480
|
+
icon: icon ?? helpers.getChainLogo(caip2),
|
|
3481
|
+
action: action,
|
|
3482
|
+
caip2: caip2,
|
|
3483
|
+
successPageDuration: successPageDuration,
|
|
3484
|
+
onSuccess: () => resolve(),
|
|
3485
|
+
onError: err => reject(err)
|
|
3486
|
+
})
|
|
3487
|
+
});
|
|
3488
|
+
});
|
|
3489
|
+
}, [ethSendErc20Transfer, getSession, pollTransactionStatus, pushPage]);
|
|
3436
3490
|
const handleOnRamp = react.useCallback(async params => {
|
|
3437
3491
|
const {
|
|
3438
3492
|
walletAccount,
|
|
@@ -3787,6 +3841,7 @@ const ClientProvider = ({
|
|
|
3787
3841
|
signMessage,
|
|
3788
3842
|
signTransaction,
|
|
3789
3843
|
ethSendTransaction,
|
|
3844
|
+
ethSendErc20Transfer,
|
|
3790
3845
|
solSendTransaction,
|
|
3791
3846
|
signAndSendTransaction,
|
|
3792
3847
|
pollTransactionStatus,
|
|
@@ -3850,7 +3905,8 @@ const ClientProvider = ({
|
|
|
3850
3905
|
handleRemoveUserPhoneNumber,
|
|
3851
3906
|
handleVerifyAppProofs,
|
|
3852
3907
|
handleOnRamp,
|
|
3853
|
-
handleSendTransaction
|
|
3908
|
+
handleSendTransaction,
|
|
3909
|
+
handleSendErc20Transfer
|
|
3854
3910
|
},
|
|
3855
3911
|
children: children
|
|
3856
3912
|
});
|