Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ jobs:
- name: Download testing extensions
run: yarn test:init
- name: Run Playwright tests
run: xvfb-run npx playwright test
run: xvfb-run yarn test
env:
PLAYWRIGHT_TEST_TIMEOUT: 120000
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/.pnp
.pnp.js
.yarn

# testing
/coverage
Expand Down Expand Up @@ -40,4 +41,7 @@ yarn-error.log*
/test-results/
/playwright-report/
/playwright/.cache/
tests/marina
tests/marina

# Cache
.cache
2 changes: 2 additions & 0 deletions .vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.next
node_modules
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
8 changes: 2 additions & 6 deletions components/providers/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { populateOffer } from 'lib/offers'
import { populateOracle } from 'lib/oracles'
import { ModalIds } from 'components/modals/modal'
import { ArtifactRepository, GitArtifactRepository } from 'lib/artifact.port'
import { ArtifactRepository, StaticArtifactRepository } from 'lib/artifact.port'

interface ConfigContextProps {
artifactRepo: ArtifactRepository
Expand All @@ -27,11 +27,7 @@ interface ConfigContextProps {
reloadConfig: () => void
}

const artifactRepo = new GitArtifactRepository({
owner: 'fuji-money',
repo: 'tapscripts',
branch: 'main',
})
const artifactRepo = new StaticArtifactRepository()

const emptyConfig = {
assets: [],
Expand Down
5 changes: 2 additions & 3 deletions components/qrcode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ function QRCode({ text }: QRCodeProps) {
options={{
type: 'image/jpeg',
quality: 0.3,
level: 'M',
margin: 0,
scale: 4,
width: 300,
color: {
dark: '#000',
light: '#fffbf800',
dark: '#000000',
light: '#ffffff',
},
}}
/>
Expand Down
230 changes: 229 additions & 1 deletion lib/artifact.port.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Artifact } from '@ionio-lang/ionio'
import { Artifact, PrimitiveType, RequirementType } from '@ionio-lang/ionio'
import { Octokit as BaseOctokit } from '@octokit/rest'
import { throttling } from '@octokit/plugin-throttling'

Expand Down Expand Up @@ -106,3 +106,231 @@ function isArtifactContentResponse(obj: any): obj is ArtifactContentResponse {
obj.encoding === 'base64'
)
}

// Add this new class that provides a hardcoded artifact
export class StaticArtifactRepository implements ArtifactRepository {
private readonly artifact: Artifact = {
contractName: 'SyntheticAsset',
constructorInputs: [
{ name: 'borrowAsset', type: PrimitiveType.Asset },
{ name: 'borrowAmount', type: PrimitiveType.Value },
{ name: 'treasuryPublicKey', type: PrimitiveType.XOnlyPublicKey },
{ name: 'expirationTimeout', type: PrimitiveType.Bytes },
{ name: 'borrowerPublicKey', type: PrimitiveType.XOnlyPublicKey },
{ name: 'oraclePublicKey', type: PrimitiveType.XOnlyPublicKey },
{ name: 'priceLevel', type: PrimitiveType.Bytes },
{ name: 'setupTimestamp', type: PrimitiveType.Bytes },
{ name: 'assetPair', type: PrimitiveType.Bytes },
],
functions: [
{
name: 'claim',
functionInputs: [
{ name: 'treasurySig', type: PrimitiveType.Signature },
],
require: [
{
type: RequirementType.Output,
atIndex: 0,
expected: {
script: {
version: -1,
program: '0x6a',
},
value: '$borrowAmount',
asset: '$borrowAsset',
nonce: '',
},
},
],
asm: [
'$expirationTimeout',
'OP_CHECKSEQUENCEVERIFY',
'OP_DROP',
'OP_0',
'OP_INSPECTOUTPUTASSET',
'OP_1',
'OP_EQUALVERIFY',
'$borrowAsset',
'OP_EQUALVERIFY',
'OP_0',
'OP_INSPECTOUTPUTVALUE',
'OP_1',
'OP_EQUALVERIFY',
'$borrowAmount',
'OP_EQUALVERIFY',
'OP_0',
'OP_INSPECTOUTPUTSCRIPTPUBKEY',
'OP_1NEGATE',
'OP_EQUALVERIFY',
'0x6a',
'OP_SHA256',
'OP_EQUALVERIFY',
'OP_0',
'OP_INSPECTOUTPUTNONCE',
'OP_0',
'OP_EQUALVERIFY',
'$treasuryPublicKey',
'OP_CHECKSIG',
],
},
{
name: 'liquidate',
functionInputs: [
{ name: 'currentPrice', type: PrimitiveType.Bytes },
{ name: 'timestamp', type: PrimitiveType.Bytes },
{ name: 'oracleSig', type: PrimitiveType.DataSignature },
{ name: 'treasurySig', type: PrimitiveType.Signature },
],
require: [
{
type: RequirementType.Output,
atIndex: 0,
expected: {
script: {
version: -1,
program: '0x6a',
},
value: '$borrowAmount',
asset: '$borrowAsset',
nonce: '',
},
},
],
asm: [
'OP_DUP',
'$priceLevel',
'OP_LESSTHAN64',
'OP_VERIFY',
'OP_OVER',
'$setupTimestamp',
'OP_GREATERTHANOREQUAL64',
'OP_VERIFY',
'OP_CAT',
'$assetPair',
'OP_CAT',
'OP_SHA256',
'$oraclePublicKey',
'OP_CHECKSIGFROMSTACKVERIFY',
'OP_0',
'OP_INSPECTOUTPUTASSET',
'OP_1',
'OP_EQUALVERIFY',
'$borrowAsset',
'OP_EQUALVERIFY',
'OP_0',
'OP_INSPECTOUTPUTVALUE',
'OP_1',
'OP_EQUALVERIFY',
'$borrowAmount',
'OP_EQUALVERIFY',
'OP_0',
'OP_INSPECTOUTPUTSCRIPTPUBKEY',
'OP_1NEGATE',
'OP_EQUALVERIFY',
'0x6a',
'OP_SHA256',
'OP_EQUALVERIFY',
'OP_0',
'OP_INSPECTOUTPUTNONCE',
'OP_0',
'OP_EQUALVERIFY',
'$treasuryPublicKey',
'OP_CHECKSIG',
],
},
{
name: 'redeem',
functionInputs: [
{ name: 'borrowerSig', type: PrimitiveType.Signature },
],
require: [
{
type: RequirementType.Output,
atIndex: 0,
expected: {
script: {
version: -1,
program: '0x6a',
},
value: '$borrowAmount',
asset: '$borrowAsset',
nonce: '',
},
},
],
asm: [
'OP_0',
'OP_INSPECTOUTPUTASSET',
'OP_1',
'OP_EQUALVERIFY',
'$borrowAsset',
'OP_EQUALVERIFY',
'OP_0',
'OP_INSPECTOUTPUTVALUE',
'OP_1',
'OP_EQUALVERIFY',
'$borrowAmount',
'OP_EQUALVERIFY',
'OP_0',
'OP_INSPECTOUTPUTSCRIPTPUBKEY',
'OP_1NEGATE',
'OP_EQUALVERIFY',
'0x6a',
'OP_SHA256',
'OP_EQUALVERIFY',
'OP_0',
'OP_INSPECTOUTPUTNONCE',
'OP_0',
'OP_EQUALVERIFY',
'$borrowerPublicKey',
'OP_CHECKSIG',
],
},
{
name: 'renew',
functionInputs: [
{ name: 'treasurySig', type: PrimitiveType.Signature },
],
require: [],
asm: [
'OP_PUSHCURRENTINPUTINDEX',
'OP_DUP',
'OP_DUP',
'OP_INSPECTINPUTASSET',
'OP_1',
'OP_EQUALVERIFY',
'OP_0',
'OP_INSPECTINPUTASSET',
'OP_1',
'OP_EQUALVERIFY',
'OP_EQUALVERIFY',
'OP_INSPECTOUTPUTVALUE',
'OP_1',
'OP_EQUALVERIFY',
'OP_0',
'OP_INSPECTOUTPUTVALUE',
'OP_1',
'OP_EQUALVERIFY',
'OP_EQUALVERIFY',
'OP_INSPECTOUTPUTSCRIPTPUBKEY',
'OP_0',
'OP_INSPECTOUTPUTSCRIPTPUBKEY',
'OP_ROT',
'OP_EQUALVERIFY',
'OP_EQUALVERIFY',
'$treasuryPublicKey',
'OP_CHECKSIG',
],
},
],
}

getLatest(): Promise<Artifact> {
return Promise.resolve(this.artifact)
}

get(timestamp: number): Promise<Artifact> {
return Promise.resolve(this.artifact)
}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"dependencies": {
"@ionio-lang/ionio": "^0.3.0",
"@octokit/core": "^5.0.0",
"@octokit/plugin-throttling": "^7.0.0",
"@octokit/rest": "^20.0.1",
"@types/tiny-secp256k1": "^2.0.1",
Expand All @@ -30,8 +31,8 @@
"marina-provider": "^2.0.0",
"next": "^12.2.2",
"next-qrcode": "^2.2.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"recharts": "^2.1.10",
"sass": "^1.49.11",
"sharp": "^0.30.7",
Expand Down
14 changes: 11 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig, devices } from '@playwright/test';
import { devices } from '@playwright/test';
import { PlaywrightTestConfig } from '@playwright/test'

/**
* Read environment variables from file.
Expand All @@ -9,7 +10,7 @@ import { defineConfig, devices } from '@playwright/test';
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
const config: PlaywrightTestConfig = {
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
Expand Down Expand Up @@ -43,4 +44,11 @@ export default defineConfig({
url: 'http://127.0.0.1:3000',
reuseExistingServer: !process.env.CI,
},
});

timeout: 120000, // Increase to 2 minutes
expect: {
timeout: 30000, // Increase expect timeout
},
};

export default config;
1 change: 1 addition & 0 deletions tests/mint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test('connect marina & use the mint page', async ({
await page.waitForSelector('text=Mint')

// go to mint and try to fill some random values
await page.waitForSelector('button:has-text("Mint")', { state: 'visible' })
await page.getByRole('button', { name: 'Mint' }).click()
await page.waitForSelector('text=Collateral Asset')
await page.getByRole('button', { name: 'Mint' }).click()
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const test = basePlaywrightTest.extend<{
context: async ({ }, use) => {
const pathToExtension = path.join(__dirname, 'marina');
const context = await chromium.launchPersistentContext('', {
headless: false,
headless: process.env.CI ? true : false,
args: [
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,
Expand Down
Loading
Loading