Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zswjs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
zswjs
Commits
aedfe2fb
Commit
aedfe2fb
authored
Mar 01, 2022
by
cf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed 1.2
parent
e2bffb19
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
23 deletions
+23
-23
09_how-to-get-table-information.md
docs/how-to-guides/09_how-to-get-table-information.md
+1
-1
package.json
package.json
+1
-1
type-checks.test.ts
src/tests/type-checks.test.ts
+1
-1
zsw-crypto-migration.test.js
src/tests/zsw-crypto-migration.test.js
+9
-9
zsw-crypto-verification.test.js
src/tests/zsw-crypto-verification.test.js
+3
-3
zswjs-jsonrpc.test.ts
src/tests/zswjs-jsonrpc.test.ts
+2
-2
zswjs-jssig.test.ts
src/tests/zswjs-jssig.test.ts
+3
-3
zswjs-numeric.ts
src/zswjs-numeric.ts
+3
-3
No files found.
docs/how-to-guides/09_how-to-get-table-information.md
View file @
aedfe2fb
...
@@ -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.
...
...
package.json
View file @
aedfe2fb
{
{
"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"
:
{
...
...
src/tests/type-checks.test.ts
View file @
aedfe2fb
...
@@ -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', 'ZSW
6nVrBASwwviMy3CntKsb1cD5Ai2gRZnyrxJDqypL3JLL7KCKrK']);
], ['
EOS7bxrQUTbQ4mqcoefhWPz1aFieN4fA9RQAiozRz7FrUChHZ7Rb8', 'EOS
6nVrBASwwviMy3CntKsb1cD5Ai2gRZnyrxJDqypL3JLL7KCKrK']);
const getAccountsByAuthorizersResult: any = {
const getAccountsByAuthorizersResult: any = {
accounts: {
accounts: {
account_name: 'string',
account_name: 'string',
...
...
src/tests/zsw-crypto-migration.test.js
View file @
aedfe2fb
...
@@ -10,9 +10,9 @@ describe('ecc Migration', () => {
...
@@ -10,9 +10,9 @@ describe('ecc Migration', () => {
'5K4XZH5XR2By7Q5KTcZnPAmUMU5yjUNBdoKzzXyrLfmiEZJqoKE'
,
'5K4XZH5XR2By7Q5KTcZnPAmUMU5yjUNBdoKzzXyrLfmiEZJqoKE'
,
];
];
const
legacyPublicKeys
=
[
const
legacyPublicKeys
=
[
'
ZSW
7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi'
,
'
EOS
7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi'
,
'
ZSW
8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F'
,
'
EOS
8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F'
,
'
ZSW
7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu'
,
'
EOS
7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu'
,
];
];
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
);
...
...
src/tests/zsw-crypto-verification.test.js
View file @
aedfe2fb
...
@@ -17,9 +17,9 @@ describe('JsSignatureProvider', () => {
...
@@ -17,9 +17,9 @@ describe('JsSignatureProvider', () => {
'5K4XZH5XR2By7Q5KTcZnPAmUMU5yjUNBdoKzzXyrLfmiEZJqoKE'
,
'5K4XZH5XR2By7Q5KTcZnPAmUMU5yjUNBdoKzzXyrLfmiEZJqoKE'
,
];
];
const
legacyPublicKeys
=
[
const
legacyPublicKeys
=
[
'
ZSW
7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi'
,
'
EOS
7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi'
,
'
ZSW
8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F'
,
'
EOS
8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F'
,
'
ZSW
7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu'
,
'
EOS
7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu'
,
];
];
const
k1FormatPublicKeys
=
[
const
k1FormatPublicKeys
=
[
'PUB_K1_7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhYTBFvY'
,
'PUB_K1_7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhYTBFvY'
,
...
...
src/tests/zswjs-jsonrpc.test.ts
View file @
aedfe2fb
...
@@ -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
({
...
...
src/tests/zswjs-jssig.test.ts
View file @
aedfe2fb
...
@@ -21,9 +21,9 @@ describe('JsSignatureProvider', () => {
...
@@ -21,9 +21,9 @@ describe('JsSignatureProvider', () => {
'PVT_R1_wCpPsaY9o8NU9ZsuwaYVQUDkCfj1aWJZGVcmMM6XyYHJVqvqp'
,
'PVT_R1_wCpPsaY9o8NU9ZsuwaYVQUDkCfj1aWJZGVcmMM6XyYHJVqvqp'
,
];
];
const
legacyPublicKeys
=
[
const
legacyPublicKeys
=
[
'
ZSW
7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi'
,
'
EOS
7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhTU9ypi'
,
'
ZSW
8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F'
,
'
EOS
8VaY5CiTexYqgQZyPTJkc3qvWuZUi12QrZL9ssjqW2es6aQk2F'
,
'
ZSW
7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu'
,
'
EOS
7VGhqctkKprW1VUj19DZZiiZLX3YcJqUJCuEcahJmUCw3wJEMu'
,
];
];
const
k1FormatPublicKeys
=
[
const
k1FormatPublicKeys
=
[
'PUB_K1_7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhYTBFvY'
,
'PUB_K1_7tgwU6E7pAUQJgqEJt66Yi8cWvanTUW8ZfBjeXeJBQvhYTBFvY'
,
...
...
src/zswjs-numeric.ts
View file @
aedfe2fb
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment