From ab3f95497a777e81c95214426e53ebf4dfdda957 Mon Sep 17 00:00:00 2001 From: Andrew Min Date: Mon, 21 Jul 2025 23:31:11 -0400 Subject: [PATCH] update with poller examples --- .../src/http/with-poller/createApiKey.ts | 13 +++++++++---- .../with-poller/createEthereumPrivateKey.ts | 19 ++++++++++++------- .../http/with-poller/createEthereumWallet.ts | 11 ++++++++--- .../src/http/with-poller/createPolicy.ts | 13 +++++++++---- .../http/with-poller/createPrivateKeyTag.ts | 13 +++++++++---- .../with-poller/createSolanaPrivateKey.ts | 19 ++++++++++++------- .../http/with-poller/createSolanaWallet.ts | 12 ++++++++---- .../http/with-poller/createSubOrganization.ts | 11 ++++++++--- .../src/http/with-poller/createUser.ts | 13 +++++++++---- .../src/http/with-poller/createUserTag.ts | 13 +++++++++---- .../src/http/with-poller/deleteWallets.ts | 13 +++++++++---- .../with-poller/setOrganizationFeature.ts | 11 ++++++++--- .../src/http/with-poller/signRawPayload.ts | 12 ++++++++---- .../src/http/with-poller/signTransaction.ts | 11 ++++++++--- .../src/http/with-poller/updateRootQuorum.ts | 11 ++++++++--- 15 files changed, 134 insertions(+), 61 deletions(-) diff --git a/examples/kitchen-sink/src/http/with-poller/createApiKey.ts b/examples/kitchen-sink/src/http/with-poller/createApiKey.ts index cc3f56eb3..33303e0d0 100644 --- a/examples/kitchen-sink/src/http/with-poller/createApiKey.ts +++ b/examples/kitchen-sink/src/http/with-poller/createApiKey.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; import { refineNonNull } from "../../utils"; @@ -24,7 +24,12 @@ async function main() { const publicKey = ""; const curveType = "API_KEY_CURVE_P256"; // this is the default - const { activity } = await turnkeyClient.createApiKeys({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.createApiKeys, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_CREATE_API_KEYS_V2", organizationId: process.env.ORGANIZATION_ID!, parameters: { @@ -37,11 +42,11 @@ async function main() { }, ], }, - timestampMs: String(Date.now()), // millisecond timestamp + timestampMs: String(Date.now()), }); const newApiKeyIds = refineNonNull( - activity.result.createApiKeysResult?.apiKeyIds, + completedActivity.result.createApiKeysResult?.apiKeyIds, ); // Success! diff --git a/examples/kitchen-sink/src/http/with-poller/createEthereumPrivateKey.ts b/examples/kitchen-sink/src/http/with-poller/createEthereumPrivateKey.ts index b0c447460..9330f138c 100644 --- a/examples/kitchen-sink/src/http/with-poller/createEthereumPrivateKey.ts +++ b/examples/kitchen-sink/src/http/with-poller/createEthereumPrivateKey.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; import * as crypto from "crypto"; import { refineNonNull } from "../../utils"; @@ -22,7 +22,12 @@ async function main() { const privateKeyName = `ETH Key ${crypto.randomBytes(2).toString("hex")}`; - const { activity } = await turnkeyClient.createPrivateKeys({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.createPrivateKeys, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_CREATE_PRIVATE_KEYS_V2", organizationId: process.env.ORGANIZATION_ID!, parameters: { @@ -35,14 +40,14 @@ async function main() { }, ], }, - timestampMs: String(Date.now()), // millisecond timestamp + timestampMs: String(Date.now()), }); - const privateKeys = refineNonNull( - activity.result.createPrivateKeysResultV2?.privateKeys, + const privateKey = refineNonNull( + completedActivity.result.createPrivateKeysResultV2?.privateKeys?.[0], ); - const privateKeyId = refineNonNull(privateKeys?.[0]?.privateKeyId); - const address = refineNonNull(privateKeys?.[0]?.addresses?.[0]?.address); + const privateKeyId = refineNonNull(privateKey.privateKeyId); + const address = refineNonNull(privateKey.addresses?.[0]?.address); // Success! console.log( diff --git a/examples/kitchen-sink/src/http/with-poller/createEthereumWallet.ts b/examples/kitchen-sink/src/http/with-poller/createEthereumWallet.ts index f0fc2c068..968851d43 100644 --- a/examples/kitchen-sink/src/http/with-poller/createEthereumWallet.ts +++ b/examples/kitchen-sink/src/http/with-poller/createEthereumWallet.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; import * as crypto from "crypto"; import { refineNonNull } from "../../utils"; @@ -22,7 +22,12 @@ async function main() { }), ); - const { activity } = await turnkeyClient.createWallet({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.createWallet, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_CREATE_WALLET", timestampMs: String(Date.now()), organizationId: process.env.ORGANIZATION_ID!, @@ -39,7 +44,7 @@ async function main() { }, }); - const wallet = refineNonNull(activity.result.createWalletResult); + const wallet = refineNonNull(completedActivity.result.createWalletResult); const walletId = refineNonNull(wallet.walletId); const address = refineNonNull(wallet.addresses[0]); diff --git a/examples/kitchen-sink/src/http/with-poller/createPolicy.ts b/examples/kitchen-sink/src/http/with-poller/createPolicy.ts index e1ea964f8..86f568bc4 100644 --- a/examples/kitchen-sink/src/http/with-poller/createPolicy.ts +++ b/examples/kitchen-sink/src/http/with-poller/createPolicy.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; import { refineNonNull } from "../../utils"; @@ -25,7 +25,12 @@ async function main() { const condition = ""; // desired condition. See https://docs.turnkey.com/concepts/policies/overview const notes = ""; - const { activity } = await turnkeyClient.createPolicy({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.createPolicy, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_CREATE_POLICY_V3", organizationId: process.env.ORGANIZATION_ID!, parameters: { @@ -35,10 +40,10 @@ async function main() { effect, notes, }, - timestampMs: String(Date.now()), // millisecond timestamp + timestampMs: String(Date.now()), }); - const policyId = refineNonNull(activity.result.createPolicyResult?.policyId); + const policyId = refineNonNull(completedActivity.result.createPolicyResult?.policyId); // Success! console.log( diff --git a/examples/kitchen-sink/src/http/with-poller/createPrivateKeyTag.ts b/examples/kitchen-sink/src/http/with-poller/createPrivateKeyTag.ts index f6f6879dd..ba93d0446 100644 --- a/examples/kitchen-sink/src/http/with-poller/createPrivateKeyTag.ts +++ b/examples/kitchen-sink/src/http/with-poller/createPrivateKeyTag.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; import { refineNonNull } from "../../utils"; @@ -22,18 +22,23 @@ async function main() { const privateKeyTagName = ""; const privateKeyIds = [""]; - const { activity } = await turnkeyClient.createPrivateKeyTag({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.createPrivateKeyTag, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_CREATE_PRIVATE_KEY_TAG", organizationId: process.env.ORGANIZATION_ID!, parameters: { privateKeyTagName, privateKeyIds, }, - timestampMs: String(Date.now()), // millisecond timestamp + timestampMs: String(Date.now()), }); const privateKeyTagId = refineNonNull( - activity.result.createPrivateKeyTagResult?.privateKeyTagId, + completedActivity.result.createPrivateKeyTagResult?.privateKeyTagId, ); // Success! diff --git a/examples/kitchen-sink/src/http/with-poller/createSolanaPrivateKey.ts b/examples/kitchen-sink/src/http/with-poller/createSolanaPrivateKey.ts index 74db6cf96..11dede271 100644 --- a/examples/kitchen-sink/src/http/with-poller/createSolanaPrivateKey.ts +++ b/examples/kitchen-sink/src/http/with-poller/createSolanaPrivateKey.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; import * as crypto from "crypto"; @@ -24,7 +24,12 @@ async function main() { const privateKeyName = `SOL Key ${crypto.randomBytes(2).toString("hex")}`; - const { activity } = await turnkeyClient.createPrivateKeys({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.createPrivateKeys, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_CREATE_PRIVATE_KEYS_V2", organizationId: process.env.ORGANIZATION_ID!, parameters: { @@ -37,14 +42,14 @@ async function main() { }, ], }, - timestampMs: String(Date.now()), // millisecond timestamp + timestampMs: String(Date.now()), }); - const privateKeys = refineNonNull( - activity.result.createPrivateKeysResultV2?.privateKeys, + const privateKey = refineNonNull( + completedActivity.result.createPrivateKeysResultV2?.privateKeys?.[0], ); - const privateKeyId = refineNonNull(privateKeys?.[0]?.privateKeyId); - const address = refineNonNull(privateKeys?.[0]?.addresses?.[0]?.address); + const privateKeyId = refineNonNull(privateKey.privateKeyId); + const address = refineNonNull(privateKey.addresses?.[0]?.address); // Success! console.log( diff --git a/examples/kitchen-sink/src/http/with-poller/createSolanaWallet.ts b/examples/kitchen-sink/src/http/with-poller/createSolanaWallet.ts index bc598b957..8dcedfc3f 100644 --- a/examples/kitchen-sink/src/http/with-poller/createSolanaWallet.ts +++ b/examples/kitchen-sink/src/http/with-poller/createSolanaWallet.ts @@ -5,7 +5,7 @@ import * as crypto from "crypto"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; import { refineNonNull } from "../../utils"; @@ -23,7 +23,12 @@ async function main() { }), ); - const { activity } = await turnkeyClient.createWallet({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.createWallet, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_CREATE_WALLET", timestampMs: String(Date.now()), organizationId: process.env.ORGANIZATION_ID!, @@ -32,7 +37,6 @@ async function main() { accounts: [ { pathFormat: "PATH_FORMAT_BIP32", - // https://github.com/satoshilabs/slips/blob/master/slip-0044.md path: "m/44'/501'/0'/0'", curve: "CURVE_ED25519", addressFormat: "ADDRESS_FORMAT_SOLANA", @@ -41,7 +45,7 @@ async function main() { }, }); - const wallet = refineNonNull(activity.result.createWalletResult); + const wallet = refineNonNull(completedActivity.result.createWalletResult); const walletId = refineNonNull(wallet.walletId); const address = refineNonNull(wallet.addresses[0]); diff --git a/examples/kitchen-sink/src/http/with-poller/createSubOrganization.ts b/examples/kitchen-sink/src/http/with-poller/createSubOrganization.ts index f91d36701..7634ceac8 100644 --- a/examples/kitchen-sink/src/http/with-poller/createSubOrganization.ts +++ b/examples/kitchen-sink/src/http/with-poller/createSubOrganization.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; import { refineNonNull } from "../../utils"; @@ -23,7 +23,12 @@ async function main() { }), ); - const { activity } = await turnkeyClient.createSubOrganization({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.createSubOrganization, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7", timestampMs: String(Date.now()), organizationId: process.env.ORGANIZATION_ID!, @@ -59,7 +64,7 @@ async function main() { }); const subOrgId = refineNonNull( - activity.result.createSubOrganizationResultV7?.subOrganizationId, + completedActivity.result.createSubOrganizationResultV7?.subOrganizationId, ); // Success! diff --git a/examples/kitchen-sink/src/http/with-poller/createUser.ts b/examples/kitchen-sink/src/http/with-poller/createUser.ts index d1bdd2c73..455371b99 100644 --- a/examples/kitchen-sink/src/http/with-poller/createUser.ts +++ b/examples/kitchen-sink/src/http/with-poller/createUser.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; import { refineNonNull } from "../../utils"; @@ -24,7 +24,12 @@ async function main() { const apiKeyName = ""; const publicKey = ""; - const { activity } = await turnkeyClient.createApiOnlyUsers({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.createApiOnlyUsers, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_CREATE_API_ONLY_USERS", organizationId: process.env.ORGANIZATION_ID!, parameters: { @@ -41,11 +46,11 @@ async function main() { }, ], }, - timestampMs: String(Date.now()), // millisecond timestamp + timestampMs: String(Date.now()), }); const userId = refineNonNull( - activity.result.createApiOnlyUsersResult?.userIds?.[0], + completedActivity.result.createApiOnlyUsersResult?.userIds?.[0], ); // Success! diff --git a/examples/kitchen-sink/src/http/with-poller/createUserTag.ts b/examples/kitchen-sink/src/http/with-poller/createUserTag.ts index 318ada45a..c324db238 100644 --- a/examples/kitchen-sink/src/http/with-poller/createUserTag.ts +++ b/examples/kitchen-sink/src/http/with-poller/createUserTag.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; import { refineNonNull } from "../../utils"; @@ -21,18 +21,23 @@ async function main() { const userTagName = ""; - const { activity } = await turnkeyClient.createUserTag({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.createUserTag, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_CREATE_USER_TAG", organizationId: process.env.ORGANIZATION_ID!, parameters: { userTagName, userIds: [], // relevant user IDs }, - timestampMs: String(Date.now()), // millisecond timestamp + timestampMs: String(Date.now()), }); const userTagId = refineNonNull( - activity.result.createUserTagResult?.userTagId, + completedActivity.result.createUserTagResult?.userTagId, ); // Success! diff --git a/examples/kitchen-sink/src/http/with-poller/deleteWallets.ts b/examples/kitchen-sink/src/http/with-poller/deleteWallets.ts index 9d40986ab..10ecee519 100644 --- a/examples/kitchen-sink/src/http/with-poller/deleteWallets.ts +++ b/examples/kitchen-sink/src/http/with-poller/deleteWallets.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; import { refineNonNull } from "../../utils"; @@ -19,18 +19,23 @@ async function main() { }), ); - const { activity } = await turnkeyClient.deleteWallets({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.deleteWallets, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_DELETE_WALLETS", organizationId: process.env.ORGANIZATION_ID!, parameters: { deleteWithoutExport: true, // this is an optional field. If this flag is not set, and the wallet has not yet been exported, this will error walletIds: [""], }, - timestampMs: String(Date.now()), // millisecond timestamp + timestampMs: String(Date.now()), }); const walletIds = refineNonNull( - activity.result.deleteWalletsResult?.walletIds, + completedActivity.result.deleteWalletsResult?.walletIds, ); // Success! diff --git a/examples/kitchen-sink/src/http/with-poller/setOrganizationFeature.ts b/examples/kitchen-sink/src/http/with-poller/setOrganizationFeature.ts index a9256009d..e214fa016 100644 --- a/examples/kitchen-sink/src/http/with-poller/setOrganizationFeature.ts +++ b/examples/kitchen-sink/src/http/with-poller/setOrganizationFeature.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; async function main() { @@ -17,7 +17,12 @@ async function main() { }), ); - const { activity } = await turnkeyClient.setOrganizationFeature({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.setOrganizationFeature, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_SET_ORGANIZATION_FEATURE", timestampMs: String(Date.now()), organizationId: process.env.ORGANIZATION_ID!, @@ -29,7 +34,7 @@ async function main() { console.log( "Successfully set organization feature. Updated features:", - activity.result.setOrganizationFeatureResult?.features, + completedActivity.result.setOrganizationFeatureResult?.features, ); } diff --git a/examples/kitchen-sink/src/http/with-poller/signRawPayload.ts b/examples/kitchen-sink/src/http/with-poller/signRawPayload.ts index 65e73d48e..a0341003c 100644 --- a/examples/kitchen-sink/src/http/with-poller/signRawPayload.ts +++ b/examples/kitchen-sink/src/http/with-poller/signRawPayload.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; async function main() { @@ -17,14 +17,18 @@ async function main() { }), ); - const { activity } = await turnkeyClient.signRawPayload({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.signRawPayload, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2", timestampMs: String(Date.now()), organizationId: process.env.ORGANIZATION_ID!, parameters: { signWith: "", payload: "", - // these parameters will largely be dependent on your use case hashFunction: "HASH_FUNCTION_NO_OP", encoding: "PAYLOAD_ENCODING_HEXADECIMAL", }, @@ -32,7 +36,7 @@ async function main() { console.log( "Successfully signed raw payload:", - activity.result.signRawPayloadResult!, + completedActivity.result.signRawPayloadResult!, ); } diff --git a/examples/kitchen-sink/src/http/with-poller/signTransaction.ts b/examples/kitchen-sink/src/http/with-poller/signTransaction.ts index 0efda8a50..4a2ec6f30 100644 --- a/examples/kitchen-sink/src/http/with-poller/signTransaction.ts +++ b/examples/kitchen-sink/src/http/with-poller/signTransaction.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; async function main() { @@ -17,7 +17,12 @@ async function main() { }), ); - const { activity } = await turnkeyClient.signTransaction({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.signTransaction, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_SIGN_TRANSACTION_V2", timestampMs: String(Date.now()), organizationId: process.env.ORGANIZATION_ID!, @@ -30,7 +35,7 @@ async function main() { console.log( "Successfully signed transaction:", - activity.result.signTransactionResult?.signedTransaction, + completedActivity.result.signTransactionResult?.signedTransaction, ); } diff --git a/examples/kitchen-sink/src/http/with-poller/updateRootQuorum.ts b/examples/kitchen-sink/src/http/with-poller/updateRootQuorum.ts index 138f23b14..849f70566 100644 --- a/examples/kitchen-sink/src/http/with-poller/updateRootQuorum.ts +++ b/examples/kitchen-sink/src/http/with-poller/updateRootQuorum.ts @@ -4,7 +4,7 @@ import * as dotenv from "dotenv"; // Load environment variables from `.env.local` dotenv.config({ path: path.resolve(process.cwd(), ".env.local") }); -import { TurnkeyClient } from "@turnkey/http"; +import { TurnkeyClient, createActivityPoller } from "@turnkey/http"; import { ApiKeyStamper } from "@turnkey/api-key-stamper"; async function main() { @@ -27,13 +27,18 @@ async function main() { organizationId: process.env.ORGANIZATION_ID!, }); - await turnkeyClient.updateRootQuorum({ + const activityPoller = createActivityPoller({ + client: turnkeyClient, + requestFn: turnkeyClient.updateRootQuorum, + }); + + const completedActivity = await activityPoller({ type: "ACTIVITY_TYPE_UPDATE_ROOT_QUORUM", timestampMs: String(Date.now()), organizationId: process.env.ORGANIZATION_ID!, parameters: { threshold: 1, - userIds: [orgConfigsResponse.configs.quorum?.userIds[0]!], // retain the first root user + userIds: [orgConfigsResponse.configs.quorum?.userIds[0]!], }, });