-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
115 additions
and
14 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ jobs: | |
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
run: | | ||
|
@@ -55,7 +55,7 @@ jobs: | |
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
node-version: 18 | ||
- uses: nevermined-io/[email protected] | ||
with: | ||
token: ${{ secrets.API_TOKEN_GITHUB }} | ||
|
@@ -97,7 +97,7 @@ jobs: | |
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
node-version: 18 | ||
- uses: nevermined-io/[email protected] | ||
with: | ||
token: ${{ secrets.API_TOKEN_GITHUB }} | ||
|
@@ -131,7 +131,7 @@ jobs: | |
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
node-version: 18 | ||
- uses: nevermined-io/[email protected] | ||
with: | ||
token: ${{ secrets.API_TOKEN_GITHUB }} | ||
|
@@ -167,7 +167,7 @@ jobs: | |
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
run: | | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ jobs: | |
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
node-version: 18 | ||
- uses: nevermined-io/[email protected] | ||
with: | ||
token: ${{ secrets.API_TOKEN_GITHUB }} | ||
|
@@ -55,7 +55,7 @@ jobs: | |
token: ${{ secrets.API_TOKEN_GITHUB }} | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
node-version: 18 | ||
|
||
- name: Deploy contracts | ||
run: | | ||
|
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 +1 @@ | ||
v12 | ||
18 |
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,90 @@ | ||
import { HDNodeWallet, Wallet } from 'ethers' | ||
import { assert } from 'chai' | ||
import { ZeroDevEthersProvider, convertEthersSignerToAccountSigner } from '@zerodev/sdk' | ||
import { | ||
Account, | ||
AssetAttributes, | ||
AssetPrice, | ||
EthSignJWT, | ||
Nevermined, | ||
NeverminedOptions, | ||
} from '../../src' | ||
import { getMetadata } from '../utils' | ||
|
||
describe('Nevermined sdk with zerodev', () => { | ||
let projectId: string | ||
let owner: HDNodeWallet | ||
let config: NeverminedOptions | ||
let nevermined: Nevermined | ||
let account: Account | ||
let zerodevProvider: ZeroDevEthersProvider<'ECDSA'> | ||
|
||
before(async () => { | ||
projectId = process.env.PROJECT_ID! | ||
owner = Wallet.createRandom() | ||
account = new Account(await owner.getAddress()) | ||
const infuraToken = process.env.INFURA_TOKEN! | ||
|
||
config = { | ||
marketplaceUri: 'https://marketplace-api.mumbai.nevermined.app', | ||
neverminedNodeUri: 'https://node.mumbai.nevermined.app', | ||
graphHttpUri: 'https://api.thegraph.com/subgraphs/name/nevermined-io/public', | ||
neverminedNodeAddress: '0x5838B5512cF9f12FE9f2beccB20eb47211F9B0bc', | ||
artifactsFolder: './artifacts', | ||
web3ProviderUri: `https://polygon-mumbai.infura.io/v3/${infuraToken}`, | ||
} | ||
}) | ||
|
||
it('should instantiate nevermined sdk with a zerodev provider', async () => { | ||
zerodevProvider = await ZeroDevEthersProvider.init('ECDSA', { | ||
projectId, | ||
owner: convertEthersSignerToAccountSigner(owner as any), | ||
}) | ||
|
||
nevermined = await Nevermined.getInstance({ | ||
...config, | ||
zerodevProvider: zerodevProvider, | ||
}) | ||
|
||
assert.isDefined(nevermined) | ||
}) | ||
|
||
it('should login to the marketplace api', async () => { | ||
const accountSigner = zerodevProvider.getAccountSigner() | ||
|
||
const clientAssertion = await new EthSignJWT({ | ||
iss: account.getId(), | ||
}) | ||
.setProtectedHeader({ alg: 'ES256K' }) | ||
.setIssuedAt() | ||
.setExpirationTime('1h') | ||
.ethSign(accountSigner as any) | ||
|
||
await nevermined.services.marketplace.login(clientAssertion) | ||
}) | ||
|
||
it('should request some nevermined tokens', async () => { | ||
const accountSigner = zerodevProvider.getAccountSigner() | ||
const accountAddress = await accountSigner.getAddress() | ||
|
||
console.log('requesting tokens for account', accountAddress) | ||
const result = await nevermined.keeper.dispenser.requestTokens(10, accountAddress) | ||
assert.isDefined(result) | ||
}) | ||
|
||
it('should create a new asset with zerodev provider', async () => { | ||
const assetAttributes = AssetAttributes.getInstance({ | ||
metadata: getMetadata(), | ||
services: [ | ||
{ | ||
serviceType: 'access', | ||
price: new AssetPrice(await owner.getAddress(), 0n), | ||
}, | ||
], | ||
providers: [config.neverminedNodeAddress], | ||
}) | ||
|
||
const ddo = await nevermined.assets.create(assetAttributes, account) | ||
assert.isDefined(ddo) | ||
}) | ||
}) |
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