- 
                Notifications
    You must be signed in to change notification settings 
- Fork 26
Add gas estimation endpoint #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
5f0ccae
              d975e94
              a535d97
              4d7c301
              f76f2a4
              a32e10f
              85d9cc1
              be76bfa
              e62ca08
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { postSafeGasEstimation } from '../src' | ||
| import config from './config' | ||
|  | ||
| describe('postSafeGasEstimation tests', () => { | ||
| it('should post a safe gas estimation', async () => { | ||
| const result = await postSafeGasEstimation(config.baseUrl, '4', '0x4f9BD57BCC68Bf7770429F137922B3afD23d83E7', { | ||
| to: '0x4f9BD57BCC68Bf7770429F137922B3afD23d83E7', | ||
| value: '1', | ||
| data: '0x', | ||
| operation: 0, | ||
| }) | ||
| console.log(result) | ||
|         
                  dasanra marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| expect(result.safeTxGas).toBe('43663') | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this deterministic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While doing the exact same operation tt should be deterministic at least until the smart contract is updated | ||
| expect(result.latestNonce).toBe(1) | ||
| }) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -14,71 +14,74 @@ jest.mock('../src/utils', () => { | |
| describe('callEndpoint', () => { | ||
| it('should accept just a path', async () => { | ||
| await expect( | ||
| callEndpoint('https://safe-client.xdai.staging.gnosisdev.com/v1', '/balances/supported-fiat-codes'), | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, how did this work before? 👀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While the not unified version is online this would work, but, as we already switched to the unified version better to update this just in case 😉 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, because it's not TypeScript. It didn't detect that this endpoint doesn't exist. | ||
| callEndpoint('https://safe-client.staging.gnosisdev.com/v1', '/chains/100/balances/supported-fiat-codes'), | ||
| ).resolves.toEqual({ success: true }) | ||
|  | ||
| expect(fetchData).toHaveBeenCalledWith( | ||
| 'https://safe-client.xdai.staging.gnosisdev.com/v1/balances/supported-fiat-codes', | ||
| 'https://safe-client.staging.gnosisdev.com/v1/chains/100/balances/supported-fiat-codes', | ||
| undefined, | ||
| ) | ||
| }) | ||
|  | ||
| it('should accept a path param', async () => { | ||
| await expect( | ||
| callEndpoint('https://safe-client.rinkeby.staging.gnosisdev.com/v1', '/safe/{address}', { | ||
| callEndpoint('https://safe-client.staging.gnosisdev.com/v1', '/chains/4/safe/{address}', { | ||
| path: { address: '0x123' }, | ||
| }), | ||
| ).resolves.toEqual({ success: true }) | ||
|  | ||
| expect(fetchData).toHaveBeenCalledWith('https://safe-client.rinkeby.staging.gnosisdev.com/v1/safe/0x123', undefined) | ||
| expect(fetchData).toHaveBeenCalledWith( | ||
| 'https://safe-client.staging.gnosisdev.com/v1/chains/4/safe/0x123', | ||
| undefined, | ||
| ) | ||
| }) | ||
|  | ||
| it('should accept several path params', async () => { | ||
| await expect( | ||
| callEndpoint('https://safe-client.rinkeby.staging.gnosisdev.com/v1', '/balances/{address}/{currency}', { | ||
| callEndpoint('https://safe-client.staging.gnosisdev.com/v1', '/chains/4/balances/{address}/{currency}', { | ||
| path: { address: '0x123', currency: 'usd' }, | ||
| }), | ||
| ).resolves.toEqual({ success: true }) | ||
|  | ||
| expect(fetchData).toHaveBeenCalledWith( | ||
| 'https://safe-client.rinkeby.staging.gnosisdev.com/v1/balances/0x123/usd', | ||
| 'https://safe-client.staging.gnosisdev.com/v1/chains/4/balances/0x123/usd', | ||
| undefined, | ||
| ) | ||
| }) | ||
|  | ||
| it('should accept query params', async () => { | ||
| await expect( | ||
| callEndpoint('https://safe-client.rinkeby.staging.gnosisdev.com/v1', '/balances/{address}/{currency}', { | ||
| callEndpoint('https://safe-client.staging.gnosisdev.com/v1', '/chains/4/balances/{address}/{currency}', { | ||
| path: { address: '0x123', currency: 'usd' }, | ||
| query: { exclude_spam: true }, | ||
| }), | ||
| ).resolves.toEqual({ success: true }) | ||
|  | ||
| expect(fetchData).toHaveBeenCalledWith( | ||
| 'https://safe-client.rinkeby.staging.gnosisdev.com/v1/balances/0x123/usd?exclude_spam=true', | ||
| 'https://safe-client.staging.gnosisdev.com/v1/chains/4/balances/0x123/usd?exclude_spam=true', | ||
| undefined, | ||
| ) | ||
| }) | ||
|  | ||
| it('should accept body', async () => { | ||
| await expect( | ||
| callEndpoint('https://safe-client.rinkeby.staging.gnosisdev.com/v1', '/transactions/{safe_address}/propose', { | ||
| callEndpoint('https://safe-client.staging.gnosisdev.com/v1', '/chains/4/transactions/{safe_address}/propose', { | ||
| path: { safe_address: '0x123' }, | ||
| body: { test: 'test' }, | ||
| }), | ||
| ).resolves.toEqual({ success: true }) | ||
|  | ||
| expect(fetchData).toHaveBeenCalledWith( | ||
| 'https://safe-client.rinkeby.staging.gnosisdev.com/v1/transactions/0x123/propose', | ||
| 'https://safe-client.staging.gnosisdev.com/v1/chains/4/transactions/0x123/propose', | ||
| { test: 'test' }, | ||
| ) | ||
| }) | ||
|  | ||
| it('should accept a raw URL', async () => { | ||
| await expect( | ||
| callEndpoint( | ||
| 'https://safe-client.rinkeby.staging.gnosisdev.com/v1', | ||
| '/balances/{address}/{currency}', | ||
| 'https://safe-client.staging.gnosisdev.com/v1', | ||
| '/chains/4/balances/{address}/{currency}', | ||
| { path: { address: '0x123', currency: 'usd' }, query: { exclude_spam: true } }, | ||
| '/test-url?raw=true', | ||
| ), | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.