Skip to content

Commit

Permalink
Merge pull request #201 from badurinantun/get-storage-at-key
Browse files Browse the repository at this point in the history
Change "getStorageAt" key type
  • Loading branch information
badurinantun authored Jun 7, 2022
2 parents b2ba2f8 + b8c60a9 commit 80a5aba
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
21 changes: 20 additions & 1 deletion __tests__/provider.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defaultProvider, stark } from '../src';
import { toBN } from '../src/utils/number';
import { compiledArgentAccount } from './fixtures';

const { compileCalldata } = stark;
Expand Down Expand Up @@ -42,7 +43,7 @@ describe('defaultProvider', () => {
)
).resolves.not.toThrow();
});
test('getStorageAt()', () => {
test('getStorageAt() with "key" type of number', () => {
return expect(
defaultProvider.getStorageAt(
'0x01d1f307c073bb786a66e6e042ec2a9bdc385a3373bb3738d95b966d5ce56166',
Expand All @@ -51,6 +52,24 @@ describe('defaultProvider', () => {
)
).resolves.not.toThrow();
});
test('getStorageAt() with "key" type of string', () => {
return expect(
defaultProvider.getStorageAt(
'0x01d1f307c073bb786a66e6e042ec2a9bdc385a3373bb3738d95b966d5ce56166',
'0',
36663
)
).resolves.not.toThrow();
});
test('getStorageAt() with "key" type of BN', () => {
return expect(
defaultProvider.getStorageAt(
'0x01d1f307c073bb786a66e6e042ec2a9bdc385a3373bb3738d95b966d5ce56166',
toBN('0x0'),
36663
)
).resolves.not.toThrow();
});
test('getStorageAt(blockHash=undefined, blockNumber=null)', () => {
return expect(
defaultProvider.getStorageAt(
Expand Down
2 changes: 1 addition & 1 deletion src/provider/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export class Provider implements ProviderInterface {
*/
public async getStorageAt(
contractAddress: string,
key: number,
key: BigNumberish,
blockIdentifier: BlockIdentifier = 'pending'
): Promise<object> {
return this.fetchEndpoint('get_storage_at', { blockIdentifier, contractAddress, key });
Expand Down
2 changes: 1 addition & 1 deletion src/provider/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export abstract class ProviderInterface {
*/
public abstract getStorageAt(
contractAddress: string,
key: number,
key: BigNumberish,
blockIdentifier?: BlockIdentifier
): Promise<object>;

Expand Down
2 changes: 1 addition & 1 deletion src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type Endpoints = {
get_storage_at: {
QUERY: {
contractAddress: string;
key: number;
key: BigNumberish;
blockIdentifier: BlockIdentifier;
};
REQUEST: never;
Expand Down

0 comments on commit 80a5aba

Please sign in to comment.