Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commit 5fc8373

Browse files
authored
Merge pull request #644 from klaytn/release/v1.8.2
[Master] release/v1.8.2 QA Sign-off
2 parents 8d39c3c + 00fd8eb commit 5fc8373

File tree

22 files changed

+869
-859
lines changed

22 files changed

+869
-859
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# @global-owner1 and @global-owner2 will be requested for
77
# review when someone opens a pull request.
88
#* @global-owner1 @global-owner2
9-
* @jimni1222 @sirano11 @aeharvlee
9+
* @jimni1222 @aeharvlee
1010

1111
# Order is important; the last matching pattern takes the most
1212
# precedence. When someone opens a pull request that only

package-lock.json

Lines changed: 576 additions & 657 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "caver-js",
3-
"version": "1.8.1",
3+
"version": "1.8.2",
44
"description": "caver-js is a JavaScript API library that allows developers to interact with a Klaytn node",
55
"main": "index.js",
66
"types": "types/index.d.ts",
@@ -70,11 +70,8 @@
7070
"any-promise": "1.3.0",
7171
"bignumber.js": "8.0.2",
7272
"bn.js": "4.11.6",
73-
"chai": "4.1.2",
7473
"constants-browserify": "^1.0.0",
7574
"crypto-browserify": "^3.12.0",
76-
"docdash": "^1.2.0",
77-
"dotenv": "8.2.0",
7875
"elliptic": "6.5.4",
7976
"eth-lib": "0.2.8",
8077
"ethers": "5.4.1",
@@ -83,22 +80,16 @@
8380
"http": "0.0.1-security",
8481
"https": "^1.0.0",
8582
"ipfs-http-client": "^49.0.4",
86-
"jsdoc": "^3.6.7",
8783
"lodash": "4.17.21",
88-
"mocha": "8.3.2",
8984
"multihashes": "4.0.2",
90-
"node-fetch": "2.6.7",
9185
"number-to-bn": "1.7.0",
9286
"oboe": "2.1.3",
9387
"os": "^0.1.2",
94-
"request": "2.88.2",
9588
"scrypt-js": "3.0.1",
96-
"semver": "6.2.0",
9789
"stream-browserify": "^3.0.0",
9890
"stream-http": "^3.2.0",
9991
"utf8": "2.1.1",
10092
"uuid": "8.3.2",
101-
"webpack": "^5.65.0",
10293
"websocket": "1.0.31",
10394
"xhr2-cookies": "1.1.0"
10495
},
@@ -114,8 +105,11 @@
114105
"babel-plugin-external-helpers": "6.22.0",
115106
"babelrc-rollup": "3.0.0",
116107
"browserify": "16.2.2",
108+
"chai": "^4.1.2",
117109
"chai-as-promised": "7.1.1",
118110
"del": "3.0.0",
111+
"docdash": "^1.2.0",
112+
"dotenv": "^8.2.0",
119113
"dtslint": "^3.4.2",
120114
"eslint": "^8.2.0",
121115
"eslint-config-airbnb": "^19.0.4",
@@ -125,17 +119,22 @@
125119
"eslint-plugin-prettier": "3.1.1",
126120
"eslint-plugin-react": "^7.28.0",
127121
"exorcist": "2.0.0",
122+
"jsdoc": "^3.6.7",
128123
"jsdoc-typeof-plugin": "^1.0.0",
129124
"jshint": "^2.13.4",
125+
"mocha": "^8.3.2",
130126
"nock": "10.0.6",
127+
"node-fetch": "^2.6.7",
131128
"nyc": "^15.1.0",
132129
"path": "0.12.7",
133130
"prettier": "1.18.2",
131+
"request": "^2.88.2",
134132
"sinon": "9.0.0",
135133
"sinon-chai": "3.5.0",
136134
"turndown": "^7.1.1",
137135
"typescript": "^4.4.4",
138136
"vinyl-source-stream": "2.0.0",
137+
"webpack": "^5.65.0",
139138
"webpack-cli": "^4.9.1"
140139
}
141140
}

packages/caver-core-method/src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const POLLINGTIMEOUT = AVERAGE_BLOCK_TIME * TIMEOUTBLOCK // ~average block time
3838

3939
const TransactionDecoder = require('../../caver-transaction/src/transactionDecoder/transactionDecoder')
4040
const { TX_TYPE_STRING } = require('../../caver-transaction/src/transactionHelper/transactionHelper')
41+
const { resolveRawKeyToAccountKey } = require('../../caver-klay/caver-klay-accounts/src/transactionType/account')
4142

4243
function Method(options) {
4344
// call, name should be existed to create a method.
@@ -427,6 +428,9 @@ const buildSendRequestFunc = (defer, sendSignedTx, sendTxCallback) => (payload,
427428
}
428429
} else if (key === 'codeFormat') {
429430
tx[key] = utils.hexToNumber(payload.params[0][key])
431+
} else if (key === 'key' && _.isObject(payload.params[0][key])) {
432+
// If key field is `AccountForUpdate`, resolve this to raw encoded account key string.
433+
tx.key = resolveRawKeyToAccountKey(payload.params[0])
430434
} else if (key === 'account') {
431435
tx.key = payload.params[0][key].getRLPEncodingAccountKey()
432436
} else if (key === 'chainId') {

packages/caver-klay/caver-klay-accounts/src/index.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,12 +1700,30 @@ function Wallet(accounts) {
17001700
this._accounts = accounts
17011701
this.length = 0
17021702
this.defaultKeyName = 'caverjs_wallet'
1703+
this.lastIndex = -1
17031704
}
17041705

17051706
Wallet.prototype._findSafeIndex = function(pointer) {
17061707
pointer = pointer || 0
1707-
if (_.has(this, pointer)) {
1708-
return this._findSafeIndex(pointer + 1)
1708+
while (this.lastIndex >= pointer) {
1709+
if (!_.has(this, pointer)) {
1710+
break
1711+
}
1712+
pointer++
1713+
}
1714+
if (this.lastIndex < pointer) {
1715+
this.lastIndex = pointer
1716+
}
1717+
return pointer
1718+
}
1719+
1720+
Wallet.prototype._findSafeLastIndex = function(pointer) {
1721+
pointer = this.lastIndex
1722+
while (pointer >= 0) {
1723+
if (_.has(this, pointer)) {
1724+
break
1725+
}
1726+
pointer--
17091727
}
17101728
return pointer
17111729
}
@@ -1905,6 +1923,11 @@ Wallet.prototype.remove = function(addressOrIndex) {
19051923

19061924
this.length--
19071925

1926+
// Update last index
1927+
if (account.index === this.lastIndex) {
1928+
this.lastIndex = this._findSafeLastIndex()
1929+
}
1930+
19081931
return true
19091932
}
19101933
return false

packages/caver-klay/caver-klay-accounts/src/transactionType/account.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
along with the caver-js. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
const _ = require('lodash')
1920
const RLP = require('eth-lib/lib/rlp')
2021
const Bytes = require('eth-lib/lib/bytes')
2122
const utils = require('../../../../caver-utils')
@@ -136,6 +137,11 @@ function rlpEncodeForFeeDelegatedAccountUpdateWithRatio(transaction) {
136137
function resolveRawKeyToAccountKey(transaction) {
137138
// Handles the case where AccountForUpdate is set in key field in transaction object to update account.
138139
if (transaction.key) {
140+
// If the key field is a string,
141+
// it means that the already encoded Account Key is passed as a parameter.
142+
if (_.isString(transaction.key)) {
143+
return transaction.key
144+
}
139145
if (transaction.from && transaction.from.toLowerCase() !== transaction.key.address.toLowerCase()) {
140146
throw new Error('The value of the from field of the transaction does not match the address of AccountForUpdate.')
141147
}
@@ -237,4 +243,5 @@ module.exports = {
237243
rlpEncodeForFeeDelegatedAccountUpdate,
238244
rlpEncodeForFeeDelegatedAccountUpdateWithRatio,
239245
parseAccountKey,
246+
resolveRawKeyToAccountKey,
240247
}

packages/caver-transaction/src/transactionHelper/transactionHelper.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,36 @@ const TX_TYPE_TAG = {
175175
'0x7802': TX_TYPE_STRING.TxTypeEthereumDynamicFee,
176176
}
177177

178+
const TX_TYPE_TAG_LEGACY_TX_TYPES = {
179+
ACCOUNT_UPDATE: TX_TYPE_TAG.TxTypeAccountUpdate,
180+
FEE_DELEGATED_ACCOUNT_UPDATE: TX_TYPE_TAG.TxTypeFeeDelegatedAccountUpdate,
181+
FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO: TX_TYPE_TAG.TxTypeFeeDelegatedAccountUpdateWithRatio,
182+
183+
VALUE_TRANFSER: TX_TYPE_TAG.TxTypeValueTransfer,
184+
FEE_DELEGATED_VALUE_TRANSFER: TX_TYPE_TAG.TxTypeFeeDelegatedValueTransfer,
185+
FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO: TX_TYPE_TAG.TxTypeFeeDelegatedValueTransferWithRatio,
186+
187+
VALUE_TRANSFER_MEMO: TX_TYPE_TAG.TxTypeValueTransferMemo,
188+
FEE_DELEGATED_VALUE_TRANSFER_MEMO: TX_TYPE_TAG.TxTypeFeeDelegatedValueTransferMemo,
189+
FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO: TX_TYPE_TAG.TxTypeFeeDelegatedValueTransferMemoWithRatio,
190+
191+
SMART_CONTRACT_DEPLOY: TX_TYPE_TAG.TxTypeSmartContractDeploy,
192+
FEE_DELEGATED_SMART_CONTRACT_DEPLOY: TX_TYPE_TAG.TxTypeFeeDelegatedSmartContractDeploy,
193+
FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO: TX_TYPE_TAG.TxTypeFeeDelegatedSmartContractDeployWithRatio,
194+
195+
SMART_CONTRACT_EXECUTION: TX_TYPE_TAG.TxTypeSmartContractExecution,
196+
FEE_DELEGATED_SMART_CONTRACT_EXECUTION: TX_TYPE_TAG.TxTypeFeeDelegatedSmartContractExecution,
197+
FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO: TX_TYPE_TAG.TxTypeFeeDelegatedSmartContractExecutionWithRatio,
198+
199+
CANCEL: TX_TYPE_TAG.TxTypeCancel,
200+
FEE_DELEGATED_CANCEL: TX_TYPE_TAG.TxTypeFeeDelegatedCancel,
201+
FEE_DELEGATED_CANCEL_WITH_RATIO: TX_TYPE_TAG.TxTypeFeeDelegatedCancelWithRatio,
202+
203+
CHAIN_DATA_ANCHORING: TX_TYPE_TAG.TxTypeChainDataAnchoring,
204+
FEE_DELEGATED_CHAIN_DATA_ANCHORING: TX_TYPE_TAG.TxTypeFeeDelegatedChainDataAnchoring,
205+
FEE_DELEGATED_CHAIN_DATA_ANCHORING_WITH_RATIO: TX_TYPE_TAG.TxTypeFeeDelegatedChainDataAnchoringWithRatio,
206+
}
207+
178208
const CODE_FORMAT = {
179209
EVM: '0x0',
180210
}
@@ -186,7 +216,12 @@ const CODE_FORMAT = {
186216
* @return {number}
187217
*/
188218
const getTypeInt = type => {
189-
return utils.hexToNumber(TX_TYPE_TAG[type])
219+
let typeInt = TX_TYPE_TAG[type]
220+
// If type int cannot be found from TX_TYPE_TAG, means old type string.
221+
if (typeInt === undefined) {
222+
typeInt = TX_TYPE_TAG_LEGACY_TX_TYPES[type]
223+
}
224+
return utils.hexToNumber(typeInt)
190225
}
191226

192227
/**

packages/caver-wallet/src/keyring/multipleKeyring.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ class MultipleKeyring {
4747
this.keys = keys
4848
}
4949

50+
/**
51+
* @type {string}
52+
*/
53+
get type() {
54+
return 'MultipleKeyring'
55+
}
56+
57+
set type(t) {
58+
throw new Error(`keyring type cannot be set.`)
59+
}
60+
5061
/**
5162
* @type {string}
5263
*/

packages/caver-wallet/src/keyring/roleBasedKeyring.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ class RoleBasedKeyring {
4848
this.keys = keys
4949
}
5050

51+
/**
52+
* @type {string}
53+
*/
54+
get type() {
55+
return 'RoleBasedKeyring'
56+
}
57+
58+
set type(t) {
59+
throw new Error(`keyring type cannot be set.`)
60+
}
61+
5162
/**
5263
* @type {string}
5364
*/

packages/caver-wallet/src/keyring/singleKeyring.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ class SingleKeyring {
4242
this.key = key
4343
}
4444

45+
/**
46+
* @type {string}
47+
*/
48+
get type() {
49+
return 'SingleKeyring'
50+
}
51+
52+
set type(t) {
53+
throw new Error(`keyring type cannot be set.`)
54+
}
55+
4556
/**
4657
* @type {string}
4758
*/

0 commit comments

Comments
 (0)