Commit aedfe2fb by cf

fixed 1.2

parent e2bffb19
...@@ -30,7 +30,7 @@ Rather than using the `get_table_rows` method, a token balance can also be retri ...@@ -30,7 +30,7 @@ Rather than using the `get_table_rows` method, a token balance can also be retri
In the example shown below, the balance of the user `testacc`'s tokens with the symbol `ZSW` stored in the `zsw.token` smart contract is retrieved. In the example shown below, the balance of the user `testacc`'s tokens with the symbol `ZSW` stored in the `zsw.token` smart contract is retrieved.
```javascript ```javascript
(async () => { (async () => {
console.log(await rpc.get_currency_balance('zsw.token', 'testacc', 'ZSW')); console.log(await rpc.get_currency_balance('zsw.token', 'testacc', 'EOS'));
})(); })();
``` ```
Above we console log the response from the 中数文联盟链 network. An example of an expected response is shown below. Above we console log the response from the 中数文联盟链 network. An example of an expected response is shown below.
......
{ {
"name": "zswjs", "name": "zswjs",
"version": "1.1.0", "version": "1.2.0",
"description": "中数文API", "description": "中数文API",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
......
...@@ -239,7 +239,7 @@ describe('Chain API Plugin Endpoints', () => { ...@@ -239,7 +239,7 @@ describe('Chain API Plugin Endpoints', () => {
const result: GetAccountsByAuthorizersResult = await rpc.get_accounts_by_authorizers([ const result: GetAccountsByAuthorizersResult = await rpc.get_accounts_by_authorizers([
{ actor: 'bob', permission: 'active' }, { actor: 'bob', permission: 'active' },
{ actor: 'cfhello', permission: 'active' } { actor: 'cfhello', permission: 'active' }
], ['ZSW7bxrQUTbQ4mqcoefhWPz1aFieN4fA9RQAiozRz7FrUChHZ7Rb8', 'ZSW6nVrBASwwviMy3CntKsb1cD5Ai2gRZnyrxJDqypL3JLL7KCKrK']); ], ['EOS7bxrQUTbQ4mqcoefhWPz1aFieN4fA9RQAiozRz7FrUChHZ7Rb8', 'EOS6nVrBASwwviMy3CntKsb1cD5Ai2gRZnyrxJDqypL3JLL7KCKrK']);
const getAccountsByAuthorizersResult: any = { const getAccountsByAuthorizersResult: any = {
accounts: { accounts: {
account_name: 'string', account_name: 'string',
......
...@@ -10,9 +10,9 @@ describe('ecc Migration', () => { ...@@ -10,9 +10,9 @@ describe('ecc Migration', () => {
'5K4XZH5XR2By7Q5KTcZnPAmUMU5yjUNBdoKzzXyrLfmiEZJqoKE', '5K4XZH5XR2By7Q5KTcZnPAmUMU5yjUNBdoKzzXyrLfmiEZJqoKE',
]; ];
const legacyPublicKeys = [ const legacyPublicKeys = [
'ZSW7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi', 'EOS7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi',
'ZSW8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F', 'EOS8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F',
'ZSW7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu', 'EOS7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu',
]; ];
it('verifies `initialize` returns console.error message', () => { it('verifies `initialize` returns console.error message', () => {
...@@ -44,8 +44,8 @@ describe('ecc Migration', () => { ...@@ -44,8 +44,8 @@ describe('ecc Migration', () => {
it('verifies `privateToPublic` function is consistent between ecc objects', () => { it('verifies `privateToPublic` function is consistent between ecc objects', () => {
console.warn = jest.fn(); console.warn = jest.fn();
const eccPublicKey = ecc.privateToPublic(privateKeys[0], 'ZSW'); const eccPublicKey = ecc.privateToPublic(privateKeys[0], 'EOS');
const eccMigrationPublicKey = eccMigration.privateToPublic(privateKeys[0], 'ZSW'); const eccMigrationPublicKey = eccMigration.privateToPublic(privateKeys[0], 'EOS');
expect(console.warn).toHaveBeenCalledWith('Argument `pubkey_prefix` is deprecated, ' + expect(console.warn).toHaveBeenCalledWith('Argument `pubkey_prefix` is deprecated, ' +
'keys prefixed with PUB_K1_/PUB_R1_/PUB_WA_ going forward'); 'keys prefixed with PUB_K1_/PUB_R1_/PUB_WA_ going forward');
expect(eccPublicKey).toEqual(eccMigrationPublicKey); expect(eccPublicKey).toEqual(eccMigrationPublicKey);
...@@ -53,8 +53,8 @@ describe('ecc Migration', () => { ...@@ -53,8 +53,8 @@ describe('ecc Migration', () => {
it('verifies `isValidPublic` function is consistent between ecc objects', () => { it('verifies `isValidPublic` function is consistent between ecc objects', () => {
console.warn = jest.fn(); console.warn = jest.fn();
const eccValid = ecc.isValidPublic(legacyPublicKeys[0], 'ZSW'); const eccValid = ecc.isValidPublic(legacyPublicKeys[0], 'EOS');
const eccMigrationValid = eccMigration.isValidPublic(legacyPublicKeys[0], 'ZSW'); const eccMigrationValid = eccMigration.isValidPublic(legacyPublicKeys[0], 'EOS');
expect(console.warn).toHaveBeenCalledWith('Argument `pubkey_prefix` is deprecated, ' + expect(console.warn).toHaveBeenCalledWith('Argument `pubkey_prefix` is deprecated, ' +
'keys prefixed with PUB_K1_/PUB_R1_/PUB_WA_ going forward'); 'keys prefixed with PUB_K1_/PUB_R1_/PUB_WA_ going forward');
expect(eccValid).toEqual(eccMigrationValid); expect(eccValid).toEqual(eccMigrationValid);
...@@ -64,8 +64,8 @@ describe('ecc Migration', () => { ...@@ -64,8 +64,8 @@ describe('ecc Migration', () => {
it('verifies `isValidPublic` function is consistent during an error', () => { it('verifies `isValidPublic` function is consistent during an error', () => {
console.warn = jest.fn(); console.warn = jest.fn();
const eccValid = ecc.isValidPublic('publickey', 'ZSW'); const eccValid = ecc.isValidPublic('publickey', 'EOS');
const eccMigrationValid = eccMigration.isValidPublic('publickey', 'ZSW'); const eccMigrationValid = eccMigration.isValidPublic('publickey', 'EOS');
expect(console.warn).toHaveBeenCalledWith('Argument `pubkey_prefix` is deprecated, ' + expect(console.warn).toHaveBeenCalledWith('Argument `pubkey_prefix` is deprecated, ' +
'keys prefixed with PUB_K1_/PUB_R1_/PUB_WA_ going forward'); 'keys prefixed with PUB_K1_/PUB_R1_/PUB_WA_ going forward');
expect(eccValid).toEqual(eccMigrationValid); expect(eccValid).toEqual(eccMigrationValid);
......
...@@ -17,9 +17,9 @@ describe('JsSignatureProvider', () => { ...@@ -17,9 +17,9 @@ describe('JsSignatureProvider', () => {
'5K4XZH5XR2By7Q5KTcZnPAmUMU5yjUNBdoKzzXyrLfmiEZJqoKE', '5K4XZH5XR2By7Q5KTcZnPAmUMU5yjUNBdoKzzXyrLfmiEZJqoKE',
]; ];
const legacyPublicKeys = [ const legacyPublicKeys = [
'ZSW7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi', 'EOS7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi',
'ZSW8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F', 'EOS8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F',
'ZSW7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu', 'EOS7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu',
]; ];
const k1FormatPublicKeys = [ const k1FormatPublicKeys = [
'PUB_K1_7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhYTBFvY', 'PUB_K1_7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhYTBFvY',
......
...@@ -202,7 +202,7 @@ describe('JSON RPC', () => { ...@@ -202,7 +202,7 @@ describe('JSON RPC', () => {
const expPath = '/v1/chain/get_currency_balance'; const expPath = '/v1/chain/get_currency_balance';
const code = 'morse'; const code = 'morse';
const account = 'myaccountaaa'; const account = 'myaccountaaa';
const symbol = 'ZSW'; const symbol = 'EOS';
const expReturn = { data: '12345' }; const expReturn = { data: '12345' };
const expParams = { const expParams = {
body: JSON.stringify({ body: JSON.stringify({
...@@ -247,7 +247,7 @@ describe('JSON RPC', () => { ...@@ -247,7 +247,7 @@ describe('JSON RPC', () => {
it('calls get_currency_stats with all params', async () => { it('calls get_currency_stats with all params', async () => {
const expPath = '/v1/chain/get_currency_stats'; const expPath = '/v1/chain/get_currency_stats';
const code = 'morse'; const code = 'morse';
const symbol = 'ZSW'; const symbol = 'EOS';
const expReturn = { data: '12345' }; const expReturn = { data: '12345' };
const expParams = { const expParams = {
body: JSON.stringify({ body: JSON.stringify({
......
...@@ -21,9 +21,9 @@ describe('JsSignatureProvider', () => { ...@@ -21,9 +21,9 @@ describe('JsSignatureProvider', () => {
'PVT_R1_wCpPsaY9o8NU9ZsuwaYVQUDkCfj1aWJZGVcmMM6XyYHJVqvqp', 'PVT_R1_wCpPsaY9o8NU9ZsuwaYVQUDkCfj1aWJZGVcmMM6XyYHJVqvqp',
]; ];
const legacyPublicKeys = [ const legacyPublicKeys = [
'ZSW7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi', 'EOS7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi',
'ZSW8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F', 'EOS8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F',
'ZSW7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu', 'EOS7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu',
]; ];
const k1FormatPublicKeys = [ const k1FormatPublicKeys = [
'PUB_K1_7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhYTBFvY', 'PUB_K1_7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhYTBFvY',
......
...@@ -312,7 +312,7 @@ export const stringToPublicKey = (s: string): Key => { ...@@ -312,7 +312,7 @@ export const stringToPublicKey = (s: string): Key => {
if (typeof s !== 'string') { if (typeof s !== 'string') {
throw new Error('expected string containing public key'); throw new Error('expected string containing public key');
} }
if (s.substr(0, 3) === 'ZSW') { if (s.substr(0, 3) === 'EOS') {
const whole = base58ToBinary(publicKeyDataSize + 4, s.substr(3)); const whole = base58ToBinary(publicKeyDataSize + 4, s.substr(3));
const key = { type: KeyType.k1, data: new Uint8Array(publicKeyDataSize) }; const key = { type: KeyType.k1, data: new Uint8Array(publicKeyDataSize) };
for (let i = 0; i < publicKeyDataSize; ++i) { for (let i = 0; i < publicKeyDataSize; ++i) {
...@@ -338,7 +338,7 @@ export const stringToPublicKey = (s: string): Key => { ...@@ -338,7 +338,7 @@ export const stringToPublicKey = (s: string): Key => {
/** Convert public `key` to legacy string (base-58) form */ /** Convert public `key` to legacy string (base-58) form */
export const publicKeyToLegacyString = (key: Key): string => { export const publicKeyToLegacyString = (key: Key): string => {
if (key.type === KeyType.k1 && key.data.length === publicKeyDataSize) { if (key.type === KeyType.k1 && key.data.length === publicKeyDataSize) {
return keyToString(key, '', 'ZSW'); return keyToString(key, '', 'EOS');
} else if (key.type === KeyType.r1 || key.type === KeyType.wa) { } else if (key.type === KeyType.r1 || key.type === KeyType.wa) {
throw new Error('Key format not supported in legacy conversion'); throw new Error('Key format not supported in legacy conversion');
} else { } else {
...@@ -363,7 +363,7 @@ export const publicKeyToString = (key: Key): string => { ...@@ -363,7 +363,7 @@ export const publicKeyToString = (key: Key): string => {
* Leaves other formats untouched * Leaves other formats untouched
*/ */
export const convertLegacyPublicKey = (s: string): string => { export const convertLegacyPublicKey = (s: string): string => {
if (s.substr(0, 3) === 'ZSW') { if (s.substr(0, 3) === 'EOS') {
return publicKeyToString(stringToPublicKey(s)); return publicKeyToString(stringToPublicKey(s));
} }
return s; return s;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment