Skip to content

Commit

Permalink
fix(SPV-999): SharedConfig type is not representing server response c…
Browse files Browse the repository at this point in the history
…orrectly. (#1069)
  • Loading branch information
dorzepowski authored Aug 16, 2024
1 parent 7d0664f commit 2d3e908
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
19 changes: 19 additions & 0 deletions examples/get-handled-paymail-domains.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { SpvWalletClient } from '../dist/typescript-npm-package.cjs.js';
import { exampleAdminKey, exampleXPriv } from './example-keys.js';
import { errMessage } from './utils.js';

const server = 'http://localhost:3003/v1';

// It is possible to get paymail domains either as an admin or as a user.
if (!exampleAdminKey && !exampleXPriv) {
console.log(errMessage('adminKey'), 'or', errMessage('xPriv'));
process.exit(1);
}

const client = exampleXPriv
? new SpvWalletClient(server, { xPriv: exampleXPriv })
: new SpvWalletClient(server, { adminKey: exampleAdminKey });

const sharedConfig = await client.GetSharedConfig();

console.log(sharedConfig.paymail_domains[0]);
5 changes: 3 additions & 2 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"preinstall": "cd ../ && yarn install && yarn build",
"build": "tsc",
"build:client": "cd .. && yarn build",
"run:example": "yarn build:client && node --loader ts-node/esm",
"run:example": "yarn build:client && echo '==== Starting ====\n' && node --loader ts-node/esm",
"admin-add-user": "yarn run:example admin-add-user.ts",
"admin-remove-user": "yarn run:example admin-remove-user.ts",
"create-transaction": "yarn run:example create-transaction.ts",
Expand All @@ -17,7 +17,8 @@
"send-op-return": "yarn run:example send-op-return.ts",
"xpriv-from-mnemonic": "yarn run:example xpriv-from-mnemonic.ts",
"xpub-from-xpriv": "yarn run:example xpub-from-xpriv.ts",
"generate-totp": "yarn run:example generate-totp.ts"
"generate-totp": "yarn run:example generate-totp.ts",
"get-handled-paymail-domains": "yarn run:example get-handled-paymail-domains.ts"
},
"version": "0.0.0",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bsv/spv-wallet-js-client",
"version": "1.0.0-beta.19",
"version": "1.0.0-beta.20",
"description": "TypeScript library for connecting to a SPV Wallet server",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,13 +678,13 @@ export interface SharedConfig {
/**
* PaymailDomains is an array of strings representing the allowed Paymail domains.
*/
PaymailDomains: string[];
paymail_domains: string[];

/**
* ExperimentalFeatures is a map of experimental features handled by spv-wallet.
* The keys are strings representing the feature names, and the values are booleans representing whether the feature is enabled or not.
*/
ExperimentalFeatures: { [key: string]: boolean };
experimental_features: { [key: string]: boolean };
}

export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE';

0 comments on commit 2d3e908

Please sign in to comment.