Skip to content

Commit deba11d

Browse files
committed
getSessionKeyData implementation
1 parent c80cabb commit deba11d

4 files changed

Lines changed: 47 additions & 5 deletions

File tree

lib/ContractInteract/GnosisSafe.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class GnosisSafe {
272272
* @return {Promise<Object>} Promise that resolves to array of owners.
273273
*/
274274
getOwners() {
275-
return this.contract.methods.getOwners().call();
275+
return Promise.resolve(this.contract.methods.getOwners().call());
276276
}
277277

278278
/**
@@ -281,7 +281,7 @@ class GnosisSafe {
281281
* @return {Promise<Object>} Promise that resolves current GnosisSafe nonce.
282282
*/
283283
getNonce() {
284-
return this.contract.methods.nonce().call();
284+
return Promise.resolve(this.contract.methods.nonce().call());
285285
}
286286

287287
/**
@@ -373,7 +373,7 @@ class GnosisSafe {
373373
* @returns {string} domain separator value.
374374
*/
375375
async getDomainSeparator() {
376-
return this.contract.methods.domainSeparator().call();
376+
return Promise.resolve(this.contract.methods.domainSeparator().call());
377377
}
378378

379379
/**
@@ -382,7 +382,7 @@ class GnosisSafe {
382382
* @returns {Object} Map of all modules.
383383
*/
384384
async getModules() {
385-
return this.contract.methods.getModules().call();
385+
return Promise.resolve(this.contract.methods.getModules().call());
386386
}
387387
}
388388

lib/ContractInteract/PricerRule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class PricerRule {
143143
const abiBinProvider = new AbiBinProvider();
144144
const bin = abiBinProvider.getBIN(ContractName);
145145

146-
const bytesBaseCurrencyCode = this.auxiliaryWeb3.utils.stringToHex(baseCurrencyCode);
146+
const bytesBaseCurrencyCode = auxiliaryWeb3.utils.stringToHex(baseCurrencyCode);
147147
const args = [
148148
organization,
149149
eip20Token,

lib/ContractInteract/TokenHolder.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@ class TokenHolder {
188188
}
189189
return Promise.resolve(this.contract.methods.executeRule(to, data, nonce, r, s, v));
190190
}
191+
192+
/**
193+
* It returns the session key data object.
194+
*
195+
* @return {Promise<Object>} Promise that resolves current GnosisSafe nonce.
196+
*/
197+
getSessionKeyData(sessionKey) {
198+
return Promise.resolve(this.contract.methods.sessionKeys().call(sessionKey));
199+
}
191200
}
192201

193202
module.exports = TokenHolder;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
3+
const Web3 = require('web3');
4+
const sinon = require('sinon');
5+
const { assert } = require('chai');
6+
7+
const Spy = require('../../../utils/Spy');
8+
const TokenHolder = require('../../../lib/ContractInteract/TokenHolder');
9+
10+
describe('TokenHolder.getLogoutExecutableData()', () => {
11+
let tokenHolder;
12+
13+
beforeEach(() => {
14+
const web3 = new Web3();
15+
const address = '0x0000000000000000000000000000000000000002';
16+
tokenHolder = new TokenHolder(web3, address);
17+
});
18+
19+
it('should construct with correct parameters', async () => {
20+
const mockSessionKeyData = 'mockSessionKeyData';
21+
const logoutSpy = sinon.replace(
22+
tokenHolder.contract.methods,
23+
'sessionKeys',
24+
sinon.fake.returns({
25+
call: () => Promise.resolve(mockSessionKeyData)
26+
})
27+
);
28+
const response = await tokenHolder.getSessionKeyData();
29+
30+
assert.strictEqual(response, mockSessionKeyData);
31+
Spy.assert(logoutSpy, 1, [[]]);
32+
});
33+
});

0 commit comments

Comments
 (0)