Skip to content

Commit

Permalink
Merge pull request #27 from skalenetwork/hotfix/add-s2s-functions
Browse files Browse the repository at this point in the history
Hotfix/add s2s functions
  • Loading branch information
dmytrotkk authored Jun 8, 2022
2 parents c40a7e0 + 58e932e commit 2b87b71
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 42 deletions.
35 changes: 15 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,38 +33,33 @@ jobs:
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
echo "Version $VERSION"
- name: Set release
run: |
if [[ "$BRANCH" == "stable" ]]; then
export PRERELEASE=false
else
export PRERELEASE=true
fi
echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV
- name: Yarn build
run: |
yarn prepack
- name: Publish on npm
if: github.ref != 'refs/heads/stable'
run: |
npm version --no-git-tag-version ${{ env.VERSION }} --allow-same-version
npm publish --access public --tag ${{ env.BRANCH }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish on npm (stable)
if: github.ref == 'refs/heads/stable'
run: |
npm publish --access public
if [[ "$BRANCH" == "stable" ]]; then
npm publish --access public
else
npm version --no-git-tag-version ${{ env.VERSION }} --allow-same-version
npm publish --access public --tag ${{ env.BRANCH }}
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Release
if: github.ref != 'refs/heads/stable'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
draft: false
prerelease: true
- name: Create Release (stable)
if: github.ref == 'refs/heads/stable'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
draft: false
prerelease: ${{ env.PRERELEASE }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ chmod +x .git/hooks/pre-commit

![GitHub](https://img.shields.io/github/license/skalenetwork/skale.py.svg)

All contributions are made under the [GNU Lesser General Public License v3](https://www.gnu.org/licenses/lgpl-3.0.en.html). See [LICENSE](LICENSE).
All contributions are made under the [GNU Lesser General Public License v3](https://www.gnu.org/licenses/lgpl-3.0.en.html). See [LICENSE](LICENSE).
2 changes: 1 addition & 1 deletion helper-scripts
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@skalenetwork/ima-js",
"version": "1.0.0",
"version": "1.0.1",
"description": "Simple TS/JS library to interact with SKALE IMA",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion skale-ima-sdk
Submodule skale-ima-sdk updated 1 files
+23 −8 inner_run.sh
6 changes: 3 additions & 3 deletions src/contracts/schain/TokenManagerERC1155.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ import InvalidArgsException from '../../exceptions/InvalidArgsException';

export class TokenManagerERC1155 extends TokenManager {

async isTokenAdded(
erc1155OnMainnet: string,
async getTokenCloneAddress(
originTokenAddress: string,
originChainName: string = constants.MAINNET_CHAIN_NAME
) {
return await this.contract.methods.clonesErc1155(
this.web3.utils.soliditySha3(originChainName),
erc1155OnMainnet
originTokenAddress
).call();
}

Expand Down
6 changes: 3 additions & 3 deletions src/contracts/schain/TokenManagerERC20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ export class TokenManagerERC20 extends TokenManager {
return await transactions.send(this.web3, txData, opts);
}

async isTokenAdded(
erc20OnMainnet: string,
async getTokenCloneAddress(
originTokenAddress: string,
originChainName: string = constants.MAINNET_CHAIN_NAME
) {
return await this.contract.methods.clonesErc20(
this.web3.utils.soliditySha3(originChainName),
erc20OnMainnet
originTokenAddress
).call();
}

Expand Down
6 changes: 3 additions & 3 deletions src/contracts/schain/TokenManagerERC721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import TxOpts from '../../TxOpts';

export class TokenManagerERC721 extends TokenManager {

async isTokenAdded(
erc721OnMainnet: string,
async getTokenCloneAddress(
originTokenAddress: string,
originChainName: string = constants.MAINNET_CHAIN_NAME
): Promise<string> {
return await this.contract.methods.clonesErc721(
this.web3.utils.soliditySha3(originChainName),
erc721OnMainnet
originTokenAddress
).call();
}

Expand Down
6 changes: 6 additions & 0 deletions src/contracts/schain/TokenManagerLinker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ export class TokenManagerLinker extends BaseContract {
return await transactions.send(this.web3, txData, opts);
}

async hasSchain(schainName: string): Promise<boolean> {
return await this.contract.methods.hasSchain(
schainName
).call();
}

}
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ export class IMA {
await this.mainnet.erc20.addTokenByOwner(chainName, erc20OnMainnet, opts);
}

const isERC20AddedSchain = await this.schain.erc20.isTokenAdded(erc20OnMainnet);
if (isERC20AddedSchain === constants.ZERO_ADDRESS) {
const tokenCloneAddress = await this.schain.erc20.getTokenCloneAddress(erc20OnMainnet);
if (tokenCloneAddress === constants.ZERO_ADDRESS) {
await this.schain.erc20.addTokenByOwner(
originChainName, erc20OnMainnet, erc20OnSchain, opts);
}
Expand All @@ -150,10 +150,10 @@ export class IMA {
await this.mainnet.erc721.addTokenByOwner(chainName, erc721OnMainnet, opts);
}

const isERC721AddedSchain = await this.schain.erc721.isTokenAdded(
const tokenCloneAddress = await this.schain.erc721.getTokenCloneAddress(
erc721OnMainnet
);
if (isERC721AddedSchain === constants.ZERO_ADDRESS) {
if (tokenCloneAddress === constants.ZERO_ADDRESS) {
await this.schain.erc721.addTokenByOwner(
originChainName, erc721OnMainnet, erc721OnSchain, opts);
}
Expand All @@ -175,10 +175,10 @@ export class IMA {
chainName, erc721OnMainnet, opts);
}

const isERC721AddedSchain = await this.schain.erc721meta.isTokenAdded(
const tokenCloneAddress = await this.schain.erc721meta.getTokenCloneAddress(
erc721OnMainnet
);
if (isERC721AddedSchain === constants.ZERO_ADDRESS) {
if (tokenCloneAddress === constants.ZERO_ADDRESS) {
await this.schain.erc721meta.addTokenByOwner(
originChainName, erc721OnMainnet, erc721OnSchain, opts);
}
Expand All @@ -196,9 +196,9 @@ export class IMA {
if (!isERC1155AddedMainnet){
await this.mainnet.erc1155.addTokenByOwner(chainName, erc1155OnMainnet, opts);
}
const isERC1155AddedSchain = await this.schain.erc1155.isTokenAdded(
const tokenCloneAddress = await this.schain.erc1155.getTokenCloneAddress(
erc1155OnMainnet);
if (isERC1155AddedSchain === constants.ZERO_ADDRESS) {
if (tokenCloneAddress === constants.ZERO_ADDRESS) {
await this.schain.erc1155.addTokenByOwner(
originChainName, erc1155OnMainnet, erc1155OnSchain, opts);
}
Expand Down
2 changes: 1 addition & 1 deletion test-tokens
Submodule test-tokens updated 1 files
+1 −1 package.json

0 comments on commit 2b87b71

Please sign in to comment.