-
Notifications
You must be signed in to change notification settings - Fork 10
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
Feat/zapper 2 #333
base: main
Are you sure you want to change the base?
Feat/zapper 2 #333
Changes from 23 commits
28d3800
d2dddc7
210aa26
fd9093f
28f0821
3233dcf
08b5a35
ea92c38
3a186b2
aa754f8
83f9cfb
6a8e432
14e90de
54a7cbc
1b08c7e
640ee04
646d1f6
47ab38b
f524f05
835a928
fca1e4f
302e298
dfa75cf
dd2abc4
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,67 @@ | ||
name: publish_package_oraiswap_v3 | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the main branch | ||
push: | ||
branches: [feat/zapper-2] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
build: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
node-version: ["18"] | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
- uses: actions/cache@v4 | ||
id: yarn-cache | ||
with: | ||
path: | | ||
${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
./node_modules/ | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install Dependencies | ||
run: yarn | ||
- name: Build | ||
run: yarn build | ||
- name: Authenticate with private NPM package | ||
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | ||
- name: Publish Oraiswap v3 | ||
id: publish-oraiswap-v3 | ||
continue-on-error: true | ||
run: yarn deploy:beta packages/oraiswap-v3 | ||
env: | ||
CI: false | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Publish Contract SDK | ||
id: publish-oraidex-contracts-sdk | ||
continue-on-error: true | ||
run: yarn deploy:beta packages/contracts-sdk | ||
env: | ||
CI: false | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Publish Contract Build | ||
id: publish-oraidex-contracts-build | ||
continue-on-error: true | ||
run: yarn deploy:beta packages/contracts-build | ||
env: | ||
CI: false | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,90 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
* This file was automatically generated by @oraichain/[email protected]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
* and run the @oraichain/ts-codegen generate command to regenerate this file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { Coin, StdFee } from "@cosmjs/amino"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
import {Addr, InstantiateMsg, ExecuteMsg, Uint128, AssetInfo, Asset, QueryMsg, MigrateMsg, ConfigResponse} from "./IncentivesFundManager.types"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
export interface IncentivesFundManagerReadOnlyInterface { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
contractAddress: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
config: () => Promise<ConfigResponse>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
export class IncentivesFundManagerQueryClient implements IncentivesFundManagerReadOnlyInterface { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
client: CosmWasmClient; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
contractAddress: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
constructor(client: CosmWasmClient, contractAddress: string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
this.client = client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
this.contractAddress = contractAddress; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
this.config = this.config.bind(this); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
config = async (): Promise<ConfigResponse> => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
return this.client.queryContractSmart(this.contractAddress, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
config: {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+24
to
+28
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. Add Error Handling in the The Apply this diff to implement error handling: config = async (): Promise<ConfigResponse> => {
+ try {
return this.client.queryContractSmart(this.contractAddress, {
config: {}
});
+ } catch (error) {
+ // Handle the error appropriately
+ throw new Error(`Failed to fetch config: ${error.message}`);
+ }
}; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
export interface IncentivesFundManagerInterface extends IncentivesFundManagerReadOnlyInterface { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
contractAddress: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
sender: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
updateConfig: ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
oraiswapV3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
owner | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
oraiswapV3?: Addr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
owner?: Addr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+30
to
+39
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. 💡 Codebase verification Inconsistent Usage of The parameter
Please update these instances to 🔗 Analysis chainVerify Consistency of Parameter Naming Ensure that parameter names are consistent across your interfaces and methods. For example, check that Run the following script to check for parameter naming consistency: Also applies to: 62-68, 76-82 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify consistent usage of parameter names 'oraiswapV3' and 'owner'.
# Search for 'oraiswapV3' occurrences
rg --type ts 'oraiswapV3[^A-Za-z0-9_]'
# Search for 'owner' occurrences
rg --type ts 'owner[^A-Za-z0-9_]'
# Ensure that the parameter names match across interfaces and implementations.
Length of output: 29938 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
sendFund: ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
asset, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
receiver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
asset: Asset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
receiver: Addr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
export class IncentivesFundManagerClient extends IncentivesFundManagerQueryClient implements IncentivesFundManagerInterface { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
client: SigningCosmWasmClient; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
sender: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
contractAddress: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+49
to
+51
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. 🛠️ Refactor suggestion Remove Redundant Assignment of In the Apply this diff to eliminate the redundant assignment: constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) {
super(client, contractAddress);
this.client = client;
this.sender = sender;
- this.contractAddress = contractAddress;
this.updateConfig = this.updateConfig.bind(this);
this.sendFund = this.sendFund.bind(this);
}
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
super(client, contractAddress); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
this.client = client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
this.sender = sender; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
this.contractAddress = contractAddress; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
this.updateConfig = this.updateConfig.bind(this); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
this.sendFund = this.sendFund.bind(this); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
updateConfig = async ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
oraiswapV3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
owner | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
oraiswapV3?: Addr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
owner?: Addr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
return await this.client.execute(this.sender, this.contractAddress, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
update_config: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
oraiswap_v3: oraiswapV3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
owner | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, _fee, _memo, _funds); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+69
to
+75
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. Handle Execution Errors in The Apply this diff to add error handling: updateConfig = async ({
oraiswapV3,
owner
}: {
oraiswapV3?: Addr;
owner?: Addr;
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
+ try {
return await this.client.execute(this.sender, this.contractAddress, {
update_config: {
oraiswap_v3: oraiswapV3,
owner
}
}, _fee, _memo, _funds);
+ } catch (error) {
+ // Handle the error appropriately
+ throw new Error(`Failed to execute updateConfig: ${error.message}`);
+ }
}; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
sendFund = async ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
asset, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
receiver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
asset: Asset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
receiver: Addr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
return await this.client.execute(this.sender, this.contractAddress, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
send_fund: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
asset, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
receiver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, _fee, _memo, _funds); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+83
to
+89
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. Handle Execution Errors in Similar to Apply this diff to add error handling: sendFund = async ({
asset,
receiver
}: {
asset: Asset;
receiver: Addr;
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
+ try {
return await this.client.execute(this.sender, this.contractAddress, {
send_fund: {
asset,
receiver
}
}, _fee, _memo, _funds);
+ } catch (error) {
+ // Handle the error appropriately
+ throw new Error(`Failed to execute sendFund: ${error.message}`);
+ }
}; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export type Addr = string; | ||
export interface InstantiateMsg { | ||
oraiswap_v3: Addr; | ||
owner?: Addr | null; | ||
} | ||
export type ExecuteMsg = { | ||
update_config: { | ||
oraiswap_v3?: Addr | null; | ||
owner?: Addr | null; | ||
}; | ||
} | { | ||
send_fund: { | ||
asset: Asset; | ||
receiver: Addr; | ||
}; | ||
}; | ||
export type Uint128 = string; | ||
export type AssetInfo = { | ||
token: { | ||
contract_addr: Addr; | ||
}; | ||
} | { | ||
native_token: { | ||
denom: string; | ||
}; | ||
}; | ||
export interface Asset { | ||
amount: Uint128; | ||
info: AssetInfo; | ||
} | ||
export type QueryMsg = { | ||
config: {}; | ||
}; | ||
Comment on lines
+31
to
+33
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. 🛠️ Refactor suggestion Consider refining the The current definition of Here's a suggested improvement: export type QueryMsg = {
config: Record<string, never>;
}; This change maintains the same functionality while addressing the static analysis warning about using 🧰 Tools🪛 Biome
|
||
export interface MigrateMsg {} | ||
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. 🛠️ Refactor suggestion Refine the The Consider changing it to a type alias if no properties are needed: export type MigrateMsg = Record<string, never>; This change maintains the same functionality while addressing the static analysis warning about empty interfaces. 🧰 Tools🪛 Biome
|
||
export interface ConfigResponse { | ||
oraiswap_v3: Addr; | ||
owner: Addr; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export type Addr = string; | ||
export type Percentage = number; | ||
export interface InstantiateMsg { | ||
incentives_fund_manager: Addr; | ||
protocol_fee: Percentage; | ||
} | ||
export type ExecuteMsg = { | ||
|
@@ -132,7 +134,6 @@ export type ExecuteMsg = { | |
index: number; | ||
}; | ||
}; | ||
export type Addr = string; | ||
export type Liquidity = string; | ||
export type SqrtPrice = string; | ||
export type TokenAmount = string; | ||
|
@@ -180,6 +181,8 @@ export type QueryMsg = { | |
admin: {}; | ||
} | { | ||
protocol_fee: {}; | ||
} | { | ||
incentives_fund_manager: {}; | ||
Comment on lines
+184
to
+185
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. Approve the new query, but refine the type definition. The addition of the Replace export type QueryMsg = {
// ... other queries ...
} | {
incentives_fund_manager: void;
} | {
// ... remaining queries ...
}; This change addresses the static analysis warning and makes the type definition more explicit. 🧰 Tools🪛 Biome
|
||
} | { | ||
position: { | ||
index: number; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Avoid Unnecessary Binding of Methods
Since you're using arrow functions for your methods, explicit binding in the constructor is unnecessary. Arrow functions lexically bind
this
, so you can safely remove these bindings to simplify the constructor.Apply this diff to remove the unnecessary bindings:
- this.config = this.config.bind(this);
Also applies to: 58-59