import { SDK, localNetStaticConfig } from "@canton-network/wallet-sdk";
export default async function () {
const sdk = await SDK.create({
auth: {
method: "self_signed",
issuer: "unsafe-auth",
credentials: {
clientId: "ledger-api-user",
clientSecret: "unsafe",
audience: "https://canton.network.global",
scope: "",
},
},
ledgerClientUrl: new URL("http://localhost:2975"),
token: {
registries: [
new URL("http://localhost:2000/api/validator/v0/scan-proxy"),
],
auth: global.TOKEN_PROVIDER_CONFIG_DEFAULT,
},
amulet: {
scanApiUrl: localNetStaticConfig.LOCALNET_SCAN_API_URL,
auth: TOKEN_PROVIDER_CONFIG_DEFAULT,
registryUrl: localNetStaticConfig.LOCALNET_REGISTRY_API_URL,
},
asset: {
registries: [localNetStaticConfig.LOCALNET_REGISTRY_API_URL],
auth: TOKEN_PROVIDER_CONFIG_DEFAULT,
},
});
// OR, you can defer loading config by calling .extend()
const basicSDK = await SDK.create({
auth: {
method: "self_signed",
issuer: "unsafe-auth",
credentials: {
clientId: "ledger-api-user",
clientSecret: "unsafe",
audience: "https://canton.network.global",
scope: "",
},
},
ledgerClientUrl: new URL("http://localhost:2975"),
});
// Extend with token namespace
const tokenExtendedSDK = await basicSDK.extend({
token: {
validatorUrl: new URL("http://localhost:2000/api/validator"),
registries: [
new URL("http://localhost:2000/api/validator/v0/scan-proxy"),
],
auth: global.TOKEN_PROVIDER_CONFIG_DEFAULT,
},
});
// Can extend further with more namespaces
const fullyExtendedSDK = await tokenExtendedSDK.extend({
amulet: {
validatorUrl: localNetStaticConfig.LOCALNET_APP_VALIDATOR_URL,
scanApiUrl: localNetStaticConfig.LOCALNET_SCAN_API_URL,
auth: global.TOKEN_PROVIDER_CONFIG_DEFAULT,
registryUrl: localNetStaticConfig.LOCALNET_REGISTRY_API_URL,
},
});
}