@ab-org/predicate-market-sdk 0.0.2 → 0.1.1
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/README.md +12 -2
- package/dist/constants/chains.d.ts +2 -22
- package/dist/constants/chains.js +3 -23
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/modules/api.d.ts +13 -8
- package/dist/modules/api.js +6 -4
- package/dist/modules/balanceQuery.d.ts +11 -4
- package/dist/modules/balanceQuery.js +12 -10
- package/dist/modules/deposit.js +2 -1
- package/dist/modules/marketData.d.ts +1 -1
- package/dist/modules/marketData.js +27 -33
- package/dist/modules/withdraw.js +2 -1
- package/dist/modules/withdrawDirect.d.ts +14 -0
- package/dist/modules/withdrawDirect.js +33 -0
- package/dist/modules/withdrawExecutor.d.ts +15 -6
- package/dist/modules/withdrawExecutor.js +22 -20
- package/dist/ui/DepositModal.d.ts +1 -1
- package/dist/ui/DepositModal.js +46 -18
- package/dist/ui/WithdrawModal.d.ts +12 -2
- package/dist/ui/WithdrawModal.js +101 -55
- package/dist/ui/components/DepositDetailsPanel.d.ts +1 -1
- package/dist/ui/components/DepositDetailsPanel.js +31 -5
- package/dist/ui/signInTypes.d.ts +3 -0
- package/dist/ui/useSignInModalController.js +1 -36
- package/dist/utils/env.js +2 -0
- package/dist/walletUtils.d.ts +1 -1
- package/dist/walletUtils.js +1 -1
- package/package.json +3 -2
|
@@ -3,7 +3,7 @@ import { getSDKConfig } from "../auth/config.js";
|
|
|
3
3
|
import { createOidcRelayAuth } from "../auth/oidcRelay.js";
|
|
4
4
|
import WalletAccount from "../auth/walletAccount.js";
|
|
5
5
|
import { getEnv } from "../utils/env.js";
|
|
6
|
-
import {
|
|
6
|
+
import { WalletConnector, createDefaultInjectedWalletRegistry, } from "@ab-org/sdk-core";
|
|
7
7
|
import { resolveWalletItems } from "./SignInModal.shared.js";
|
|
8
8
|
function resolveOidcStage() {
|
|
9
9
|
return getEnv("STAGE").toLowerCase() === "prod" ? "prod" : "dev";
|
|
@@ -13,7 +13,6 @@ export const useSignInModalController = ({ wallets, initialVisibleCount, onGoogl
|
|
|
13
13
|
const [loadingProvider, setLoadingProvider] = useState(null);
|
|
14
14
|
const [loadingWalletId, setLoadingWalletId] = useState(null);
|
|
15
15
|
const defaultWalletRegistry = useMemo(() => createDefaultInjectedWalletRegistry(), []);
|
|
16
|
-
const sdkConfig = getSDKConfig();
|
|
17
16
|
const defaultWalletConnector = useMemo(() => new WalletConnector([
|
|
18
17
|
...defaultWalletRegistry.map((item) => item.provider),
|
|
19
18
|
]), [defaultWalletRegistry]);
|
|
@@ -21,30 +20,6 @@ export const useSignInModalController = ({ wallets, initialVisibleCount, onGoogl
|
|
|
21
20
|
const showExpandToggle = resolvedWallets.length > initialVisibleCount;
|
|
22
21
|
const visibleWallets = expanded ? resolvedWallets : resolvedWallets.slice(0, initialVisibleCount);
|
|
23
22
|
const isBusy = !!loadingProvider || !!loadingWalletId;
|
|
24
|
-
const confirmCapabilitySession = async (providerId, cubeSignerSession) => {
|
|
25
|
-
const confirmation = sdkConfig.signIn?.sessionConfirmation;
|
|
26
|
-
const policy = cubeSignerSession && sdkConfig.cubeSigner
|
|
27
|
-
? {
|
|
28
|
-
id: "preview",
|
|
29
|
-
...(sdkConfig.signIn?.sessionPolicy ?? sdkConfig.cubeSigner.defaultSessionPolicy),
|
|
30
|
-
}
|
|
31
|
-
: undefined;
|
|
32
|
-
if (confirmation?.enabled === false || !policy) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
if (typeof window === "undefined" || typeof window.confirm !== "function") {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
const lines = describeSessionCapabilityPolicy(policy);
|
|
39
|
-
const message = [
|
|
40
|
-
confirmation?.title ?? "Authorize smart-wallet session",
|
|
41
|
-
confirmation?.message ?? `Continue with ${providerId} and create a capability session?`,
|
|
42
|
-
...lines,
|
|
43
|
-
]
|
|
44
|
-
.filter(Boolean)
|
|
45
|
-
.join("\n");
|
|
46
|
-
return window.confirm(message);
|
|
47
|
-
};
|
|
48
23
|
const handleSocialClick = async (providerId) => {
|
|
49
24
|
setLoadingProvider(providerId);
|
|
50
25
|
try {
|
|
@@ -67,11 +42,6 @@ export const useSignInModalController = ({ wallets, initialVisibleCount, onGoogl
|
|
|
67
42
|
await WalletAccount.getInstance(oidcToken, authSource, config.cubeSigner);
|
|
68
43
|
const session = WalletAccount.getWalletSession();
|
|
69
44
|
const cubeSignerSession = WalletAccount.getCubeSignerSession();
|
|
70
|
-
const confirmed = await confirmCapabilitySession(providerId, cubeSignerSession);
|
|
71
|
-
if (!confirmed) {
|
|
72
|
-
WalletAccount.clearInstance();
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
45
|
onGoogleLogin?.({ idToken: oidcToken });
|
|
76
46
|
if (cubeSignerSession)
|
|
77
47
|
onCubeSignerSession?.(cubeSignerSession);
|
|
@@ -91,11 +61,6 @@ export const useSignInModalController = ({ wallets, initialVisibleCount, onGoogl
|
|
|
91
61
|
await WalletAccount.getInstance(oidcToken, authSource, config.cubeSigner);
|
|
92
62
|
const session = WalletAccount.getWalletSession();
|
|
93
63
|
const cubeSignerSession = WalletAccount.getCubeSignerSession();
|
|
94
|
-
const confirmed = await confirmCapabilitySession(providerId, cubeSignerSession);
|
|
95
|
-
if (!confirmed) {
|
|
96
|
-
WalletAccount.clearInstance();
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
64
|
onTwitterLogin?.({ code: "", codeVerifier: "", state: "" });
|
|
100
65
|
if (cubeSignerSession)
|
|
101
66
|
onCubeSignerSession?.(cubeSignerSession);
|
package/dist/utils/env.js
CHANGED
|
@@ -28,6 +28,8 @@ function readProcessEnvStatic(key) {
|
|
|
28
28
|
return pick(process.env.NEXT_PUBLIC_CUBE_REG, process.env.CUBE_REG);
|
|
29
29
|
case "RELAY_ORIGIN":
|
|
30
30
|
return pick(process.env.NEXT_PUBLIC_RELAY_ORIGIN, process.env.RELAY_ORIGIN);
|
|
31
|
+
case "FUNDING_TOKEN_SYMBOL":
|
|
32
|
+
return pick(process.env.NEXT_PUBLIC_FUNDING_TOKEN_SYMBOL, process.env.FUNDING_TOKEN_SYMBOL) || "USDT";
|
|
31
33
|
default:
|
|
32
34
|
return undefined;
|
|
33
35
|
}
|
package/dist/walletUtils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { getEnv } from "./utils/env.js";
|
|
2
2
|
export { getExplorerUrl } from "./utils/explorer.js";
|
|
3
|
-
export {
|
|
3
|
+
export { ClientIds, DEFAULT_FUNDING_TOKEN_ADDRESS, DEFAULT_FUNDING_CHAIN_ID, getFundingTokenAddress, getChainInfo, type EvmChainInfo, } from "./constants/chains.js";
|
package/dist/walletUtils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { getEnv } from "./utils/env.js";
|
|
2
2
|
export { getExplorerUrl } from "./utils/explorer.js";
|
|
3
|
-
export {
|
|
3
|
+
export { ClientIds, DEFAULT_FUNDING_TOKEN_ADDRESS, DEFAULT_FUNDING_CHAIN_ID, getFundingTokenAddress, getChainInfo, } from "./constants/chains.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ab-org/predicate-market-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**/*",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"@cubist-labs/cubesigner-sdk": "^0.4.219",
|
|
24
24
|
"axios": "^1.13.6",
|
|
25
25
|
"qrcode-generator": "^2.0.4",
|
|
26
|
-
"@ab-org/sdk-core": "0.0.1"
|
|
26
|
+
"@ab-org/sdk-core": "0.0.1",
|
|
27
|
+
"@ab-org/wallet-utils": "0.0.7"
|
|
27
28
|
},
|
|
28
29
|
"peerDependencies": {
|
|
29
30
|
"react": ">=18",
|