Skip to content

Commit

Permalink
chore: uses eth_chainId
Browse files Browse the repository at this point in the history
  • Loading branch information
zone-live committed Aug 12, 2024
1 parent 458872f commit 25650a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 71 deletions.
30 changes: 0 additions & 30 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -521,36 +521,6 @@ <h4>
</div>
</div>
</div>

<div
class="col-xl-4 col-lg-6 col-md-12 col-sm-12 col-12 d-flex align-items-stretch"
>
<div class="card full-width">
<div class="card-body">
<h4 class="card-title">
Sign in to compliance
</h4>

<p class="info-text alert alert-success">
Project ID: <input name="compliance-project-id" id="complianceProjectId" value="ded5f9c0-e55c-4c0a-ac86-3dd513e876f0" />
&nbsp;
Client ID: <input name="compliance-client-id" id="complianceClientId" value="5kQHg48BQJR2QuGTs1EX4V5OJZI8RA2k" />
</p>

<button
class="btn btn-primary btn-lg btn-block mb-3"
id="complianceButton"
>
Add token
</button>

<p class="info-text alert alert-secondary">
Result: <span id="complianceResult">Not clicked</span>
</p>

</div>
</div>
</div>
</section>

</main>
Expand Down
43 changes: 2 additions & 41 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ const signTypedDataV4Verify = document.getElementById('signTypedDataV4Verify')
const signTypedDataV4VerifyResult = document.getElementById('signTypedDataV4VerifyResult')

const signTypedContentsId = document.getElementById('signTypedContentsId')
const complianceProjectId = document.getElementById('complianceProjectId')
const complianceClientId = document.getElementById('complianceClientId')

const complianceButton = document.getElementById('complianceButton')
const complianceResult = document.getElementById('complianceResult')

const disableSections = (disable) => {
for (let i = 0; i < sectionClass.length; i++) {
Expand Down Expand Up @@ -221,7 +216,7 @@ const initialize = async () => {

const updateButtons = async () => {
const networkId = Number(await ethereum.request({
method: 'net_version',
method: 'eth_chainId',
}))
const accountButtonsDisabled = !isMetaMaskInstalled() || !isMetaMaskConnected() || networkId === 1
if (accountButtonsDisabled) {
Expand Down Expand Up @@ -933,40 +928,6 @@ const initialize = async () => {
}
}

complianceButton.onclick = async () => {
const projectId = complianceProjectId.value
const clientId = complianceClientId.value

try {
const result = await window.ethereum.request({
'method': 'metamaskinstitutional_authenticate',
'params': {
'origin': 'mmitest.compliance.codefi.network',
'token': {
clientId,
projectId,
},
'feature': 'compliance',
'service': 'codefi-compliance',
'labels': [
{
'key': 'service',
'value': 'Codefi Compliance',
},
{
'key': 'token.projectId',
'value': 'Some project name',
},
],
},
})

complianceResult.innerHTML = result
} catch (err) {
complianceResult.innerHTML = `Error: ${err.message}`
}
}

function handleNewAccounts(newAccounts) {
accounts = newAccounts
accountsDiv.innerHTML = accounts
Expand All @@ -993,7 +954,7 @@ const initialize = async () => {
handleNewChain(chainId)

const networkId = await ethereum.request({
method: 'net_version',
method: 'eth_chainId',
})
handleNewNetwork(networkId)
} catch (err) {
Expand Down

0 comments on commit 25650a2

Please sign in to comment.