-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from terra-money/feat/smartaccs
Feat/smartaccs
- Loading branch information
Showing
19 changed files
with
1,034 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Setting } from '../../../core/smartaccount/v1/models/Setting'; | ||
import { SmartaccountParams } from '../../../core/smartaccount/v1/models/SmartaccountParams'; | ||
import { LCDClient } from '../LCDClient'; | ||
import { SmartaccountAPI } from './SmartaccountAPI'; | ||
|
||
const lcd = new LCDClient({ | ||
'pisco-1': { | ||
chainID: 'pisco-1', | ||
gasAdjustment: 1.5, | ||
gasPrices: { | ||
uluna: 0.02, | ||
}, | ||
lcd: 'http://localhost:1317/', | ||
prefix: 'terra', | ||
}, | ||
}); | ||
const smartaccount = new SmartaccountAPI(lcd); | ||
|
||
describe('SmartaccountAPI', () => { | ||
it('assert the module params', async () => { | ||
const res = await smartaccount.params('pisco-1'); | ||
|
||
expect(res).toStrictEqual(new SmartaccountParams()); | ||
|
||
expect(res.toData()).toEqual({}); | ||
}); | ||
|
||
// test with wallet15 terra1tck9vx8vwu6l83zy76ssdkhnhw8dfcrt80hc6x | ||
it('assert the account setting', async () => { | ||
const res = await smartaccount.setting( | ||
'terra1tck9vx8vwu6l83zy76ssdkhnhw8dfcrt80hc6x' | ||
); | ||
expect(res.toData()).toEqual({ | ||
owner: 'terra1tck9vx8vwu6l83zy76ssdkhnhw8dfcrt80hc6x', | ||
authorization: [], | ||
post_transaction: [], | ||
pre_transaction: [], | ||
fallback: true, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Setting } from '../../../core/smartaccount'; | ||
import { AccAddress } from '../../../core'; | ||
import { LCDClient } from '../LCDClient'; | ||
import { BaseAPI } from './BaseAPI'; | ||
import { SmartaccountParams } from '../../../core/smartaccount'; | ||
|
||
export class SmartaccountAPI extends BaseAPI { | ||
constructor(public lcd: LCDClient) { | ||
super(lcd.apiRequesters, lcd.config); | ||
} | ||
|
||
/** | ||
* Query the feemarket module params. | ||
* | ||
* @tags Query | ||
* @name params | ||
* @request GET:/terra/smartaccount/v1/params | ||
*/ | ||
public async params(chainId: string): Promise<SmartaccountParams> { | ||
const res = await this.getReqFromChainID(chainId).get<{ | ||
params: SmartaccountParams.Data; | ||
}>(`/terra/smartaccount/v1/params`); | ||
|
||
return SmartaccountParams.fromData(res.params); | ||
} | ||
|
||
/** | ||
* Query the feemarket module setting for account. | ||
* | ||
* @tags Query | ||
* @name setting | ||
* @request GET:/terra/smartaccount/v1/setting/{account} | ||
*/ | ||
public async setting(account: AccAddress): Promise<Setting> { | ||
const res = await this.getReqFromAddress(account).get<{ | ||
setting: Setting.Data; | ||
}>(`/terra/smartaccount/v1/setting/${account}`); | ||
|
||
return Setting.fromData(res.setting); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './v1/msgs'; | ||
export * from './v1/models/Initialization'; | ||
export * from './v1/models/AuthorizationMsg'; | ||
export * from './v1/models/Setting'; | ||
export * from './v1/models/SmartaccountParams'; |
Oops, something went wrong.