diff --git a/.github/workflows/docs-bot.yml b/.github/workflows/docs-bot.yml new file mode 100644 index 000000000..981703ba8 --- /dev/null +++ b/.github/workflows/docs-bot.yml @@ -0,0 +1,22 @@ +name: Docs Bot +on: + push: + branches: + - main +jobs: + generate-docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 14.x + - run: npm ci + - run: npm run docs + - name: Do git actions + run: | + git config user.email "janek@argent.xyz" + git config user.name "Docs Bot" + git add --force -- docs/README.md + git commit -m "docs: add generated docs" + git push diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 000000000..8c79fab94 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,25 @@ +name: Node.js CI +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: + - 14.x + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm run build --if-present + - run: npm test diff --git a/.gitignore b/.gitignore index 14109b61a..f737d86c4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ dist npm-debug.log .env .DS_Store + +docs/README.md diff --git a/README.md b/README.md index 8b5209265..e9c889f8a 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@
+
diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts
index 2ab40f4c3..087ce5959 100644
--- a/__tests__/index.test.ts
+++ b/__tests__/index.test.ts
@@ -1,4 +1,4 @@
-import * as starknet from '../index';
+import * as starknet from '../';
describe('starknet endpoints', () => {
describe('feeder gateway endpoints', () => {
diff --git a/docs/README.md b/docs/README.md
index b0ccea8ef..e690ccd82 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -39,7 +39,7 @@ a confirmation of invoking a function on the starknet contract
#### Defined in
-[index.ts:156](https://github.com/seanjameshan/starknet.js/blob/505f231/src/index.ts#L156)
+[index.ts:156](https://github.com/argentlabs/starknet.js/blob/6a0a989/src/index.ts#L156)
___
@@ -66,7 +66,7 @@ the result of the function on the smart contract.
#### Defined in
-[index.ts:33](https://github.com/seanjameshan/starknet.js/blob/505f231/src/index.ts#L33)
+[index.ts:33](https://github.com/argentlabs/starknet.js/blob/6a0a989/src/index.ts#L33)
___
@@ -92,7 +92,7 @@ the block object { block_id, previous_block_id, state_root, status, timestamp, t
#### Defined in
-[index.ts:52](https://github.com/seanjameshan/starknet.js/blob/505f231/src/index.ts#L52)
+[index.ts:52](https://github.com/argentlabs/starknet.js/blob/6a0a989/src/index.ts#L52)
___
@@ -119,7 +119,7 @@ ABI of compiled contract in JSON
#### Defined in
-[index.ts:72](https://github.com/seanjameshan/starknet.js/blob/505f231/src/index.ts#L72)
+[index.ts:72](https://github.com/argentlabs/starknet.js/blob/6a0a989/src/index.ts#L72)
___
@@ -139,7 +139,7 @@ starknet smart contract address
#### Defined in
-[index.ts:13](https://github.com/seanjameshan/starknet.js/blob/505f231/src/index.ts#L13)
+[index.ts:13](https://github.com/argentlabs/starknet.js/blob/6a0a989/src/index.ts#L13)
___
@@ -167,7 +167,7 @@ the value of the storage variable
#### Defined in
-[index.ts:93](https://github.com/seanjameshan/starknet.js/blob/505f231/src/index.ts#L93)
+[index.ts:93](https://github.com/argentlabs/starknet.js/blob/6a0a989/src/index.ts#L93)
___
@@ -193,7 +193,7 @@ the transacton object { transaction_id, status, transaction, block_id?, block_nu
#### Defined in
-[index.ts:137](https://github.com/seanjameshan/starknet.js/blob/505f231/src/index.ts#L137)
+[index.ts:137](https://github.com/argentlabs/starknet.js/blob/6a0a989/src/index.ts#L137)
___
@@ -219,4 +219,4 @@ the transaction status object { block_id, tx_status: NOT_RECEIVED | RECEIVED | P
#### Defined in
-[index.ts:118](https://github.com/seanjameshan/starknet.js/blob/505f231/src/index.ts#L118)
+[index.ts:118](https://github.com/argentlabs/starknet.js/blob/6a0a989/src/index.ts#L118)
diff --git a/src/index.d.ts b/src/index.d.ts
new file mode 100644
index 000000000..12182e90a
--- /dev/null
+++ b/src/index.d.ts
@@ -0,0 +1,68 @@
+export interface GetContractAddressesResponse {
+ Starknet: string;
+ GpsStatementVerifier: string;
+}
+
+export type Status = 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'REJECTED' | 'ACCEPTED_ONCHAIN';
+export type Type = 'DEPLOY' | 'INVOKE_FUNCTION';
+export type EntryPointType = 'EXTERNAL';
+
+export interface Transaction {
+ type: Type;
+ contract_address: string;
+ entry_point_type?: EntryPointType;
+ entry_point_selector?: string;
+ calldata?: string[];
+}
+
+export interface GetBlockResponse {
+ sequence_number: number;
+ state_root: string;
+ block_id: number;
+ transactions: {
+ [txid: string]: Transaction;
+ };
+ timestamp: number;
+ transaction_receipts: {
+ [txid: string]: {
+ block_id: number;
+ transaction_id: number;
+ l2_to_l1_messages: {
+ to_address: string;
+ payload: string[];
+ from_address: string;
+ }[];
+ block_number: number;
+ status: Status;
+ transaction_index: number;
+ };
+ };
+ previous_block_id: number;
+ status: Status;
+}
+
+export interface Abi {
+ inputs: { name: string; type: string }[];
+ name: string;
+ outputs: { name: string; type: string }[];
+ type: string;
+}
+
+export interface GetCode {
+ bytecode: string[];
+ abi: Abi[];
+}
+
+export interface GetTransactionStatusResponse {
+ tx_status: Status;
+ block_id: number;
+}
+
+export interface GetTransactionResponse {
+ transaction_index: number;
+ transaction: Transaction;
+ block_id: number;
+ block_number: number;
+ status: Status;
+ transaction_id: number;
+}
diff --git a/src/index.ts b/src/index.ts
index 19dbc567e..3da4c440e 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,5 +1,13 @@
import axios from 'axios';
+import type {
+ GetBlockResponse,
+ GetCode,
+ GetContractAddressesResponse,
+ GetTransactionResponse,
+ GetTransactionStatusResponse,
+} from './index.d';
+
const API_URL: string = 'https://alpha2.starknet.io/';
const FEEDER_GATEWAY_URL: string = `${API_URL}/feeder_gateway`;
const GATEWAY_URL: string = `${API_URL}/gateway`;
@@ -8,19 +16,20 @@ const GATEWAY_URL: string = `${API_URL}/gateway`;
* Gets the smart contract address on the goerli testnet.
*
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L13-L15)
- * @returns starknet smart contract address
+ * @returns starknet smart contract addresses
*/
-export function getContractAddresses(): Promise