Skip to content

Commit 7505664

Browse files
committed
Deprecate parcelSigner and parcelFee options in the SDK constructor
It confuses that the parcelSigner option only works with sendParcel() in spite of there is signParcel(). Also, the option isn't used anywhere in the examples.
1 parent 384ad85 commit 7505664

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/index.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,37 @@ class SDK {
3939
/**
4040
* @param params.server HTTP RPC server address
4141
* @param params.keyStoreType Specify the type of the keystore. The default value is "local". It creates keystore.db file on the working directory.
42-
* @param params.options.networkId The network id of CodeChain. The default value is "tc" (testnet)
43-
* @param params.options.parcelSigner The default account to sign the parcel
44-
* @param params.options.parcelFee The default amount for the parcel fee
42+
* @param params.networkId The network id of CodeChain. The default value is "tc" (testnet)
4543
*/
4644
constructor(params: {
4745
server: string;
4846
keyStoreType?: KeyStoreType;
47+
networkId?: NetworkId;
48+
// Deprecated. It will be removed at 0.2.0
4949
options?: {
5050
networkId?: NetworkId;
5151
parcelSigner?: string;
5252
parcelFee?: number;
5353
};
5454
}) {
55-
const { server, keyStoreType = "local", options = {} } = params;
56-
const { networkId = "tc", parcelSigner, parcelFee = 10 } = options;
55+
const {
56+
server,
57+
keyStoreType = "local",
58+
networkId = "tc",
59+
options
60+
} = params;
61+
const {
62+
networkId: networkIdOpt,
63+
parcelSigner,
64+
parcelFee = 10
65+
} = options || { networkId: undefined, parcelSigner: undefined };
5766

5867
this.rpc = new Rpc({ server, options: { parcelSigner, parcelFee } });
59-
this.core = new Core({ networkId });
60-
this.key = new Key({ networkId, keyStoreType });
68+
this.core = new Core({ networkId: networkIdOpt || networkId });
69+
this.key = new Key({
70+
networkId: networkIdOpt || networkId,
71+
keyStoreType
72+
});
6173
}
6274
}
6375

0 commit comments

Comments
 (0)