Coder Social home page Coder Social logo

squid-sdk's People

Contributors

0x0koda avatar 0x1notme avatar dependabot[bot] avatar ecdsafu avatar genaroibc avatar github-actions[bot] avatar jack0son avatar jmdev3 avatar juanmavillarrazadb avatar lint-action avatar nnoln avatar odcey avatar rajat43 avatar rrigoni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

squid-sdk's Issues

[SDK] Not enough funds provides error on `squid.isRouteApproved`

Description / Steps to reproduce

We don't allow to check for approval using the SDK function if the user doesn't have enough funds in their account. This seems incorrect, we should return true or false, even if they don't have enough funds.

Error: Insufficient funds for account: 0x7dBd0F75aA91c757ae6564d41dd59669023D57a4 on chain 43114
    at EvmHandler.validateTokenBalance (/Users/fig/code/squid/examples/V2/sdk/swapAvalancheUsdcToMoonbeam/node_modules/@0xsquid/sdk/src/handlers/evm/utils.ts:45:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async EvmHandler.validateBalance (/Users/fig/code/squid/examples/V2/sdk/swapAvalancheUsdcToMoonbeam/node_modules/@0xsquid/sdk/src/handlers/evm/index.ts:85:14)
    at async EvmHandler.isRouteApproved (/Users/fig/code/squid/examples/V2/sdk/swapAvalancheUsdcToMoonbeam/node_modules/@0xsquid/sdk/src/handlers/evm/index.ts:194:20)
    at async Squid.isRouteApproved (/Users/fig/code/squid/examples/V2/sdk/swapAvalancheUsdcToMoonbeam/node_modules/@0xsquid/sdk/src/index.ts:183:16)
Waiting for the debugger to disconnect...
error Command failed with exit code 1.

Acceptance Criteria

  • Users of the SDK can use isRouteApproved even if a user doesn't have enough funds in their account.

[SDK/Testing] Add new test case for send only transaction

Description/Reasoning

Add new test case in scripts for send only transaction

Acceptance Criteria

  • SDK test suites also verified send only transaction

Current Behaviour

Expected Behaviour

Steps to reproduce (for bugs)

Relevant Logs or Files

[SDK] V2 Integrate V2 types and API endpoint

Description

  • release and integrate squid-types packages
  • implement v2 API endpoint
  • update API response validation

Acceptance Criteria

  • SDK should support v1/v2
  • Validate API response base on v1/v2 API endpoint
  • release v2 beta package for SDK

[SDK] Get all balances

Continuation of this task https://docs.google.com/document/d/1eM_tP0Ct_DjhSTf9Rdq5_r8fwj0JfRhiSNCknab495Y/edit

Expose a method on the sdk called getAllBalances({ chainIds?: string[], cosmosAddress?: string, evmAddress?: string })

  • cosmosAddress will need to have its own type, according to how you built getAllCosmosBalances not a string

Which internally decides based on the argument passed if it's going to call to getAlllEvmBalances or getAllCosmosBalances

The main idea of chainIds argument is to allow only fetch balances given a chain, like by a single RPC I can get all token balances on ethereum

  • if chainIds is provided, then only get balances for the chainIds provided.
  • if chainIds is not provided, get balance for all chains compatible with the addresses given

[sdk] Add check if the signer is on the chainId as fromChain

Description / Steps to reproduce

this is a common problem for devs using our SDK. Partners are not used to developing cross chain and a simple error message to show this would save a lot of dev time.

Add a function to the SDK which checks if a signer is on the correct chain for a route, returning (isCorrectChainId: Boolean, message String)

const signerChainId = parseInt(await provider.send("eth_chainId", []), 16).toString();
if (signerChainId !== route.params.fromChain) {
    // throw error "signer is on the wrong chain ID (${signerChainId}). Please use a signer on chain ID ${route.params.fromChain.chainId}"
}

Acceptance Criteria

  • isCorrectChainId is available on the SDK

[improvement] CHANGELOG.md order & duplicates

Description

The CHANGELOG.md has duplicate entries and misordered commits. Some commits are incorrectly categorized under the wrong version.

Acceptance Criteria

  • CHANGELOG.md accurately reflects git history, without duplicates, and with commits correctly categorized by version.

Relevant Logs or Files

Refer to CHANGELOG.md.

[SDK] [Partner Tracking] Implement partner ID property

A SDK user should be able to provide a partner tracking ID which is passed as header to the backend
for route and status requests

X-Squid-Partner-ID: your-unique-identifier
  • validate the partner-ID format
  • set http header

[SDK] Signer is not allowed to be passed into

Description

Frontend integration require the option to pass in a signer.
The current type definition require a wallet rather a signer.

modify the type to access both and handle the difference in accessing the address.

Acceptance Criteria

  • accept both signer and wallet

Invalid BigNumberish value

Description/Reasoning

I have been integrating squid sdk swap into my react app... All are okay until executing route.

const { route } = await squid.getRoute({
      toAddress: signer.address.toString(),
      fromChain: fromToken.chainId.toString(),
      fromToken: fromToken.address.toString(),
      fromAmount: '10000000000000000',
      toChain: toToken.chainId.toString(),
      toToken: toToken.address.toString(),
      slippage: 0.5,
  });
  // customContractCalls: [],
  // enableExpress: false, // default is true on all chains except Ethereum
  // receiveGasOnDestination: true,

  // const _gasLimit = ethers.toBigInt(route.transactionRequest.gasLimit);
  route.transactionRequest.gasLimit = parseInt(route.transactionRequest.gasLimit);
  // console.log('gas', route.transactionRequest);
  console.log('gas limit', typeof route.transactionRequest.gasLimit, route.transactionRequest.gasLimit);
  console.log('Gonna execute', route);

  try {
      const executionSettings = {
          setGasPrice: true,
      };
      const tx = await squid.executeRoute({
          signer,
          route,
          executionSettings,
      });
      console.log('waiting tx');
      const txReceipt = await tx.wait();
  } catch (e) {
      console.error('errror', e.message);
      console.log(e);
  }

Even tried converting the gasLimit into Number, BigInt, String manually.

Acceptance Criteria

  • [ ]

Current Behaviour

TypeError: invalid BigNumberish value (argument="request.gasLimit", value={ "hex": "0x055b58", "type": "BigNumber" }, code=INVALID_ARGUMENT, version=6.7.0)
    makeError errors.ts:678
    assert errors.ts:702
    assertArgument errors.ts:714
    getBigInt maths.ts:113
    copyRequest provider.ts:338
    populate abstract-signer.ts:32
    populateTransaction abstract-signer.ts:98
    sendTransaction abstract-signer.ts:232
    executeRoute index.ts:339

Expected Behaviour

Steps to reproduce (for bugs)

Relevant Logs or Files

Screenshot from 2023-08-09 08-55-20

Migraton V1 -> v2

I was on a react (cra) v4 version which I migrated to V5 so that it was compatible with version 2.8.9 of @0xsquid/sdk.
Once react migration from v4 to "react-scripts": "5.0.1"
However I get this error after making all the changes advised in the documentation for the migration from V1 to V2 : Docs.

I initialize squid like this:
const squid = new Squid({ baseUrl: 'https://v2.api.squidrouter.com', integratorId: "My-key" });

With "ethers": "^5.7.2",

tokenList.jsx:38 Uncaught TypeError: 0xsquid_sdk_dist_types__WEBPACK_IMPORTED_MODULE_3_.Squid is not a constructor

Then when i change the version of "ethers" to "^6.7.1" like mention on the documentation i got those errors :

Uncaught Error: Cannot find module 'ethers/lib/utils.js'
at webpackMissingModule

Need help and more clarification on this error please.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.