-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: token linker with gas service (#8)
* feature(token-linking): adding the gas service * feature(token-linker): renaming contracts * chore(build): removing interface copying from the artifacts * chore(dist): removing dist from git * chore(ignore): git and npm * feature(linkers): support for refund address * fix(workflow): test after build * fix(Linkers): constant CONTRACT_ID for Upgradable
- Loading branch information
Showing
23 changed files
with
563 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,8 @@ jobs: | |
- name: Install Dependencies | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Test | ||
run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,121 @@ | ||
node_modules | ||
artifacts | ||
typechain | ||
examples/metamask/chain*.json | ||
examples/metamask/abi/**.json | ||
**/.DS_Store | ||
./test.js | ||
./quick.json | ||
local.json | ||
temp.js | ||
temp2.js | ||
|
||
#Hardhat files | ||
cache | ||
build | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
coverage.json | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# Next.js build output | ||
.next | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and *not* Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Build | ||
artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Modules | ||
node_modules | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
env | ||
.credentials | ||
credentials | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# builder cache | ||
.cache | ||
|
||
# workflows | ||
.github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import { IAxelarGateway } from '../interfaces/IAxelarGateway.sol'; | ||
import { IAxelarGasService } from '../interfaces/IAxelarGasService.sol'; | ||
import { AxelarExecutable } from '../executables/AxelarExecutable.sol'; | ||
import { AddressToString, StringToAddress } from '../StringAddressUtils.sol'; | ||
import { Upgradable } from '../upgradables/Upgradable.sol'; | ||
|
||
abstract contract NftLinkerBase is AxelarExecutable, Upgradable { | ||
using StringToAddress for string; | ||
using AddressToString for address; | ||
|
||
bytes32 internal constant CONTRACT_ID = keccak256('nft-linker'); | ||
IAxelarGasService public immutable gasService; | ||
|
||
constructor(address gatewayAddress, address gasServiceAddress_) AxelarExecutable(gatewayAddress) { | ||
gasService = IAxelarGasService(gasServiceAddress_); | ||
} | ||
|
||
function contractId() external pure override returns (bytes32) { | ||
return CONTRACT_ID; | ||
} | ||
|
||
function sendNft( | ||
string memory destinationChain, | ||
address to, | ||
uint256 tokenId, | ||
address refundAddress | ||
) external payable virtual { | ||
string memory thisAddress = address(this).toString(); | ||
_takeNft(msg.sender, tokenId); | ||
bytes memory payload = abi.encode(to, tokenId); | ||
if (msg.value > 0) { | ||
gasService.payNativeGasForContractCall{ value: msg.value }( | ||
address(this), | ||
destinationChain, | ||
thisAddress, | ||
payload, | ||
refundAddress | ||
); | ||
} | ||
gateway.callContract(destinationChain, thisAddress, payload); | ||
} | ||
|
||
function _execute( | ||
string calldata, /*sourceChain*/ | ||
string calldata sourceAddress, | ||
bytes calldata payload | ||
) internal override { | ||
if (sourceAddress.toAddress() != address(this)) return; | ||
(address recipient, uint256 tokenId) = abi.decode(payload, (address, uint256)); | ||
_giveNft(recipient, tokenId); | ||
} | ||
|
||
function _giveNft(address to, uint256 tokenId) internal virtual; | ||
|
||
function _takeNft(address from, uint256 tokenId) internal virtual; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.