Skip to content

Commit

Permalink
update formatting and deps (#27)
Browse files Browse the repository at this point in the history
* update formatting and deps

* drop support for node 8
  • Loading branch information
cheeseandcereal authored Mar 25, 2020
1 parent 1d995f2 commit ab63753
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 212 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ branches:
- production
language: node_js
node_js:
- "8"
- "10"
- "12"
install:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 4.3.4

- **Development:**
- Drop support for node 8
- Update prettier formatter to v2
- Update dependencies

## 4.3.3

- **Bug Fix:**
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dragonchain-sdk",
"version": "4.3.3",
"version": "4.3.4",
"description": "Dragonchain SDK for Node.JS and the Browser",
"license": "Apache-2.0",
"homepage": "https://github.com/dragonchain/dragonchain-sdk-javascript#readme",
Expand All @@ -20,7 +20,7 @@
"module": "dist/index.js",
"types": "dist/types/index.d.ts",
"engines": {
"node": ">=8"
"node": ">=10.13.0"
},
"scripts": {
"build": "rm -rf dist/ && tsc",
Expand Down Expand Up @@ -83,22 +83,22 @@
"@types/chai": "^4.2.11",
"@types/ini": "^1.3.30",
"@types/mocha": "^7.0.2",
"@types/node": "^13.9.2",
"@types/node": "^12.12.31",
"@types/node-fetch": "^2.5.5",
"@types/sinon": "^7.5.2",
"@types/sinon-chai": "^3.2.3",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"@typescript-eslint/eslint-plugin": "^2.25.0",
"@typescript-eslint/parser": "^2.25.0",
"chai": "^4.2.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-config-prettier": "^6.10.1",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"prettier": "^1.19.1",
"prettier": "^2.0.2",
"sinon": "^9.0.1",
"sinon-chai": "^3.5.0",
"ts-node": "^8.7.0",
"typedoc": "^0.17.1",
"ts-node": "^8.8.1",
"typedoc": "^0.17.3",
"typescript": "^3.8.3"
}
}
4 changes: 2 additions & 2 deletions src/services/config-service/ConfigCient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const getCredsFromFile = async (dragonchainId: string, injected: any = { readFil
if (!auth_key || !auth_key_id) return false;
return {
authKey: auth_key,
authKeyId: auth_key_id
authKeyId: auth_key_id,
};
};

Expand Down Expand Up @@ -230,5 +230,5 @@ export {
getEndpointFromFile,
getCredsFromFile,
getEndpointFromRemote,
getCredsAsSmartContract
getCredsAsSmartContract,
};
4 changes: 2 additions & 2 deletions src/services/config-service/ConfigClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('ConfigClient', () => {
return {
json: () => {
return { url: 'test' };
}
},
};
};
expect(await ConfigClient.getEndpointFromRemote('id', { fetch: fakeFetch })).to.equal('test');
Expand All @@ -143,7 +143,7 @@ describe('ConfigClient', () => {
return {
json: () => {
return { notUrl: 'test' };
}
},
};
};
try {
Expand Down
5 changes: 1 addition & 4 deletions src/services/credential-service/CredentialService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ export class CredentialService {
*/
private static getHmacMessageString = (method: string, path: string, dragonchainId: string, timestamp: string, contentType: string, body: string, hmacAlgo: HmacAlgorithm) => {
const binaryBody = Buffer.from(body || '', 'utf-8');
const hashedBase64Content = crypto
.createHash(hmacAlgo)
.update(binaryBody)
.digest('base64');
const hashedBase64Content = crypto.createHash(hmacAlgo).update(binaryBody).digest('base64');
return [method.toUpperCase(), path, dragonchainId, timestamp, contentType, hashedBase64Content].join('\n');
};
}
74 changes: 37 additions & 37 deletions src/services/dragonchain-client/DragonchainClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ describe('DragonchainClient', () => {
headers: {
dragonchain: 'fakeDragonchainId',
Authorization: 'fakeCreds',
timestamp: fakeTime
}
timestamp: fakeTime,
},
};
});

Expand Down Expand Up @@ -154,7 +154,7 @@ describe('DragonchainClient', () => {
offset: 1,
idsOnly: false,
sortAscending: false,
sortBy: 'whatever'
sortBy: 'whatever',
});
assert.calledWith(
fetch,
Expand All @@ -166,7 +166,7 @@ describe('DragonchainClient', () => {
it('defaults offset and limit', async () => {
await client.queryTransactions({
transactionType: 'test',
redisearchQuery: 'yeah'
redisearchQuery: 'yeah',
});
assert.calledWith(fetch, 'fakeUrl/v1/transaction?transaction_type=test&q=yeah&offset=0&limit=10', expectedFetchOptions);
});
Expand All @@ -180,7 +180,7 @@ describe('DragonchainClient', () => {

it('defaults offset and limit', async () => {
await client.queryBlocks({
redisearchQuery: 'yeah'
redisearchQuery: 'yeah',
});
assert.calledWith(fetch, 'fakeUrl/v1/block?q=yeah&offset=0&limit=10', expectedFetchOptions);
});
Expand Down Expand Up @@ -241,9 +241,9 @@ describe('DragonchainClient', () => {
headers: {
dragonchain: 'fakeDragonchainId',
Authorization: 'fakeCreds',
timestamp: fakeTime
timestamp: fakeTime,
},
body: undefined
body: undefined,
};

describe('.deleteSmartContract', () => {
Expand Down Expand Up @@ -291,8 +291,8 @@ describe('DragonchainClient', () => {
'Content-Type': 'application/json',
dragonchain: 'fakeDragonchainId',
Authorization: 'fakeCreds',
timestamp: fakeTime
}
timestamp: fakeTime,
},
};

describe('.createApiKey', () => {
Expand All @@ -308,13 +308,13 @@ describe('DragonchainClient', () => {
const transactionCreatePayload = {
transactionType: 'transaction',
payload: 'hi!',
tag: 'Awesome!'
tag: 'Awesome!',
};
const expectedBody = {
version: '1',
txn_type: transactionCreatePayload.transactionType,
payload: transactionCreatePayload.payload,
tag: transactionCreatePayload.tag
tag: transactionCreatePayload.tag,
};
await client.createTransaction(transactionCreatePayload);
const obj = { ...expectedFetchOptions, body: JSON.stringify(expectedBody) };
Expand All @@ -335,14 +335,14 @@ describe('DragonchainClient', () => {
options: {
no_index: false,
weight: 0.5,
sortable: true
}
}
]
sortable: true,
},
},
],
};
await client.createTransactionType({
transactionType: 'testing',
customIndexFields: [{ path: 'testPath', fieldName: 'someField', type: 'text', options: { noIndex: false, sortable: true, weight: 0.5 } }]
customIndexFields: [{ path: 'testPath', fieldName: 'someField', type: 'text', options: { noIndex: false, sortable: true, weight: 0.5 } }],
});
const obj = { ...expectedFetchOptions, body: JSON.stringify(expectedBody) };
assert.calledWith(fetch, 'fakeUrl/v1/transaction-type', obj);
Expand All @@ -356,7 +356,7 @@ describe('DragonchainClient', () => {
image: 'ubuntu:latest',
environmentVariables: { banana: 'banana', apple: 'banana' },
cmd: 'banana',
args: ['-m', 'cool']
args: ['-m', 'cool'],
};
const expectedBody = {
version: '3',
Expand All @@ -365,7 +365,7 @@ describe('DragonchainClient', () => {
execution_order: 'parallel',
cmd: contractPayload.cmd,
args: contractPayload.args,
env: contractPayload.environmentVariables
env: contractPayload.environmentVariables,
};
await client.createSmartContract(contractPayload);
const obj = { ...expectedFetchOptions, body: JSON.stringify(expectedBody) };
Expand All @@ -381,7 +381,7 @@ describe('DragonchainClient', () => {
value: '0x0',
data: '0x111',
gasPrice: '0x222',
gas: '0x333'
gas: '0x333',
};
const expectedBody = {
network: transactionCreatePayload.network,
Expand All @@ -390,8 +390,8 @@ describe('DragonchainClient', () => {
value: transactionCreatePayload.value,
data: transactionCreatePayload.data,
gasPrice: transactionCreatePayload.gasPrice,
gas: transactionCreatePayload.gas
}
gas: transactionCreatePayload.gas,
},
};
await client.createEthereumTransaction(transactionCreatePayload);
const obj = { ...expectedFetchOptions, body: JSON.stringify(expectedBody) };
Expand All @@ -408,7 +408,7 @@ describe('DragonchainClient', () => {
private_key: 'abcd',
rpc_address: 'some rpc',
rpc_authorization: 'some auth',
utxo_scan: false
utxo_scan: false,
};
await client.createBitcoinInterchain({ name: 'banana', testnet: true, privateKey: 'abcd', rpcAddress: 'some rpc', rpcAuthorization: 'some auth', utxoScan: false });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
Expand All @@ -423,7 +423,7 @@ describe('DragonchainClient', () => {
name: 'banana',
private_key: 'private key',
rpc_address: 'some rpc',
chain_id: 12
chain_id: 12,
};
await client.createEthereumInterchain({ name: 'banana', privateKey: 'private key', rpcAddress: 'some rpc', chainId: 12 });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
Expand All @@ -440,7 +440,7 @@ describe('DragonchainClient', () => {
private_key: 'abcd',
node_url: 'some IP',
rpc_port: 1234,
api_port: 5678
api_port: 5678,
};
await client.createBinanceInterchain({ name: 'banana', testnet: true, privateKey: 'abcd', nodeURL: 'some IP', rpcPort: 1234, apiPort: 5678 });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
Expand All @@ -455,7 +455,7 @@ describe('DragonchainClient', () => {
fee: 4,
data: 'someData',
change: 'change address',
outputs: [{ to: 'toaddr', value: 1.234 }]
outputs: [{ to: 'toaddr', value: 1.234 }],
};
await client.signBitcoinTransaction({ name: 'banana', satoshisPerByte: 4, data: 'someData', changeAddress: 'change address', outputs: [{ to: 'toaddr', value: 1.234 }] });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
Expand All @@ -472,7 +472,7 @@ describe('DragonchainClient', () => {
data: 'someData',
gasPrice: 'gas price',
gas: 'gas',
nonce: 'nonce'
nonce: 'nonce',
};
await client.signEthereumTransaction({ name: 'banana', to: 'some addr', value: 'some value', data: 'someData', gasPrice: 'gas price', gas: 'gas', nonce: 'nonce' });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
Expand All @@ -487,7 +487,7 @@ describe('DragonchainClient', () => {
amount: 123,
to_address: 'receiver addy',
symbol: 'TOKEN',
memo: 'for bananas'
memo: 'for bananas',
};
await client.signBinanceTransaction({ name: 'banana', amount: 123, toAddress: 'receiver addy', symbol: 'TOKEN', memo: 'for bananas' });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
Expand All @@ -500,7 +500,7 @@ describe('DragonchainClient', () => {
const fakeBody: any = {
version: '1',
blockchain: 'bitcoin',
name: 'banana'
name: 'banana',
};
await client.setDefaultInterchainNetwork({ name: 'banana', blockchain: 'bitcoin' });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
Expand All @@ -514,7 +514,7 @@ describe('DragonchainClient', () => {
version: '1',
blockchain: 'bitcoin',
name: 'banana',
signed_txn: 'banana'
signed_txn: 'banana',
};
await client.publishInterchainTransaction({ name: 'banana', blockchain: 'bitcoin', signedTransaction: 'banana' });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
Expand All @@ -539,8 +539,8 @@ describe('DragonchainClient', () => {
'Content-Type': 'application/json',
dragonchain: 'fakeDragonchainId',
Authorization: 'fakeCreds',
timestamp: fakeTime
}
timestamp: fakeTime,
},
};

describe('.updateApiKey', () => {
Expand All @@ -557,7 +557,7 @@ describe('DragonchainClient', () => {
const status = 'active';
const fakeBodyResponse: any = {
version: '3',
desired_state: status
desired_state: status,
};
await client.updateSmartContract({ smartContractId, enabled: true });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBodyResponse) };
Expand All @@ -582,8 +582,8 @@ describe('DragonchainClient', () => {
'Content-Type': 'application/json',
dragonchain: 'fakeDragonchainId',
Authorization: 'fakeCreds',
timestamp: fakeTime
}
timestamp: fakeTime,
},
};

describe('.updateBitcoinInterchain', () => {
Expand All @@ -594,7 +594,7 @@ describe('DragonchainClient', () => {
private_key: 'abcd',
rpc_address: 'some rpc',
rpc_authorization: 'some auth',
utxo_scan: false
utxo_scan: false,
};
await client.updateBitcoinInterchain({ name: 'banana', testnet: true, privateKey: 'abcd', rpcAddress: 'some rpc', rpcAuthorization: 'some auth', utxoScan: false });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
Expand All @@ -608,7 +608,7 @@ describe('DragonchainClient', () => {
version: '1',
private_key: 'abcd',
rpc_address: 'some rpc',
chain_id: 12
chain_id: 12,
};
await client.updateEthereumInterchain({ name: 'banana', privateKey: 'abcd', rpcAddress: 'some rpc', chainId: 12 });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
Expand All @@ -624,7 +624,7 @@ describe('DragonchainClient', () => {
private_key: 'abcd',
node_url: 'some IP',
rpc_port: 1234,
api_port: 5678
api_port: 5678,
};
await client.updateBinanceInterchain({ name: 'banana', testnet: true, privateKey: 'abcd', nodeURL: 'some IP', rpcPort: 1234, apiPort: 5678 });
const obj = { ...expectedFetchOptions, body: JSON.stringify(fakeBody) };
Expand Down
Loading

0 comments on commit ab63753

Please sign in to comment.